On Tue, Nov 12, 2024 at 1:49 PM H.J. Lu <hjl.to...@gmail.com> wrote:
>
> When passing 0xff as an unsigned char function argument, the C frontend
> promotion will promote it to int:
>
> <integer_cst 0x7fffe6aa23a8 type <integer_type 0x7fffe98225e8 int> constant 
> 255>
>
> and expand_normal always returns the rtx value using the sign-extended
> representation,
>
> (const_int 255 [0xff])
>
> If the C frontend doesn't promote unsigned char to int, expand_normal will
> get
>
> <integer_cst 0x7fffe9824018 type <integer_type 0x7fffe9822348 unsigned char > 
> co
> nstant 255>
>
> and return
>
> (const_int -1 [0xffffffffffffffff])

that looks wrong to me, but in other places we ensure
to use trunc_int_for_mode (), not some odd function like
you introduce here?

Richard.

>
> gnu-tgl-3:pts/6[168]> head -50
> /tmp/0001-i386-Add-ix86_expand_integer_cst_argument.patch
> From d9dddaad6254cca11b0a55c18291180d6d8d7524 Mon Sep 17 00:00:00 2001
> From: "H.J. Lu" <hjl.to...@gmail.com>
> Date: Tue, 12 Nov 2024 09:03:31 +0800
> Subject: [PATCH] i386: Add ix86_expand_integer_cst_argument
>
> When passing 0xff as an unsigned char function argument, the C frontend
> promotion will promote it to int:
>
> <integer_cst 0x7fffe6aa23a8 type <integer_type 0x7fffe98225e8 int> constant 
> 255>
>
> and expand_normal always returns the rtx value using the sign-extended
> representation,
>
> (const_int 255 [0xff])
>
> If the C frontend doesn't promote unsigned char to int, expand_normal will
> get
>
> <integer_cst 0x7fffe9824018 type <integer_type 0x7fffe9822348 unsigned char > 
> co
> nstant 255>
>
> and return
>
> (const_int -1 [0xffffffffffffffff])
>
> Add ix86_expand_integer_cst_argument to expand the argument before calling
> fixup_modeless_constant to extract the 8-bit/16-bit integer constants to
> always return
>
> (const_int 255 [0xff])
>
> in this case.
>
> PR middle-end/14907
> * config/i386/i386-expand.cc (ix86_expand_integer_cst_argument):
> New function.
> (ix86_expand_args_builtin): Call ix86_expand_integer_cst_argument
> to expand the argument before calling fixup_modeless_constant.
> (ix86_expand_round_builtin): Likewise.
> (ix86_expand_special_args_builtin): Likewise.
> (ix86_expand_builtin): Likewise.
>
> --
> H.J.

Reply via email to