On Mon, Mar 28, 2011 at 5:47 PM, Richard Sandiford <richard.sandif...@linaro.org> wrote: > This patch fixes a case where expand_builtin_memset_args was creating > a zero- rather than sign-extended character-sized CONST_INT. The problem > showed up on s390, where a character was being passed as (const_int 171) > rather than (const_int -85). > > Tested on x86_64-linux-gnu. Andreas also confirms that it fixes > the s390 failure. OK to install?
Ok. Thanks, Richard. > Richard > > > gcc/ > * builtins.c (expand_builtin_memset_args): Use gen_int_mode > instead of GEN_INT. > > Index: gcc/builtins.c > =================================================================== > --- gcc/builtins.c 2011-03-24 15:13:39.000000000 +0000 > +++ gcc/builtins.c 2011-03-28 13:56:31.000000000 +0100 > @@ -3935,6 +3935,7 @@ expand_builtin_memset_args (tree dest, t > { > tree fndecl, fn; > enum built_in_function fcode; > + enum machine_mode val_mode; > char c; > unsigned int dest_align; > rtx dest_mem, dest_addr, len_rtx; > @@ -3969,14 +3970,14 @@ expand_builtin_memset_args (tree dest, t > > len_rtx = expand_normal (len); > dest_mem = get_memory_rtx (dest, len); > + val_mode = TYPE_MODE (unsigned_char_type_node); > > if (TREE_CODE (val) != INTEGER_CST) > { > rtx val_rtx; > > val_rtx = expand_normal (val); > - val_rtx = convert_to_mode (TYPE_MODE (unsigned_char_type_node), > - val_rtx, 0); > + val_rtx = convert_to_mode (val_mode, val_rtx, 0); > > /* Assume that we can memset by pieces if we can store > * the coefficients by pieces (in the required modes). > @@ -3987,8 +3988,7 @@ expand_builtin_memset_args (tree dest, t > builtin_memset_read_str, &c, dest_align, > true)) > { > - val_rtx = force_reg (TYPE_MODE (unsigned_char_type_node), > - val_rtx); > + val_rtx = force_reg (val_mode, val_rtx); > store_by_pieces (dest_mem, tree_low_cst (len, 1), > builtin_memset_gen_str, val_rtx, dest_align, > true, 0); > @@ -4014,7 +4014,8 @@ expand_builtin_memset_args (tree dest, t > true)) > store_by_pieces (dest_mem, tree_low_cst (len, 1), > builtin_memset_read_str, &c, dest_align, true, 0); > - else if (!set_storage_via_setmem (dest_mem, len_rtx, GEN_INT (c), > + else if (!set_storage_via_setmem (dest_mem, len_rtx, > + gen_int_mode (c, val_mode), > dest_align, expected_align, > expected_size)) > goto do_libcall; >