Hi Alexey,

On 12/11/2024 08:18, Alexey Merzlyakov wrote:
> gcc/ChangeLog:
> 
>       * simplify-rtx.cc (simplify_context::simplify_unary_operation_1):
>       Fix subreg mode check during zero_extend(not) -> xor optimization.
> 
> gcc/testsuite/ChangeLog:
> 
>       * gcc.dg/pr117476.c: New test.
> 
> Signed-off-by: Alexey Merzlyakov <alexey.merzlya...@samsung.com>
> ---
>  gcc/simplify-rtx.cc             |  2 +-
>  gcc/testsuite/gcc.dg/pr117476.c | 12 ++++++++++++
>  2 files changed, 13 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/gcc.dg/pr117476.c
> 
> diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc
> index d05efac20dc..2a9cabaad09 100644
> --- a/gcc/simplify-rtx.cc
> +++ b/gcc/simplify-rtx.cc
> @@ -1856,7 +1856,7 @@ simplify_context::simplify_unary_operation_1 (rtx_code 
> code, machine_mode mode,
>         && subreg_lowpart_p (op)
>         && GET_MODE_SIZE (GET_MODE (op)).is_constant ()
>         && (nonzero_bits (XEXP (XEXP (op, 0), 0), mode)
> -           & ~GET_MODE_MASK (mode)) == 0)
> +           & ~GET_MODE_MASK (GET_MODE (op))) == 0)
>        {
>       const uint64_t mask = GET_MODE_MASK (GET_MODE (op));
>       return simplify_gen_binary (XOR, mode,
> diff --git a/gcc/testsuite/gcc.dg/pr117476.c b/gcc/testsuite/gcc.dg/pr117476.c
> new file mode 100644
> index 00000000000..b8f51e697bf
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/pr117476.c

I think it might be better to put the test in gcc.c-torture/execute,
then it will automatically get run with the various torture options
and you should be able to drop both the dejagnu directives.

Thanks,
Alex

> @@ -0,0 +1,12 @@
> +/* PR rtl-optimization/117476 */
> +/* { dg-do run } */
> +/* { dg-options "-O1" } */
> +
> +int c = 0x1FF;
> +
> +int main()
> +{
> +  if (((c ^ 0xFF) & 0xFF) != 0)
> +    __builtin_abort();
> +  return 0;
> +}
> -- 
> 2.34.1

Reply via email to