Updated testsuite/ChangeLog with respect to the original testcase author -- >8 --
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. From Zhendong Su. 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 @@ -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