Hi, Alex,

On Tue, Nov 12, 2024 at 11:46:54AM +0000, Alex Coplan wrote:
> 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
Yep. Now it is going through more options at runtime. Thank you for the
suggestion.

Updated patch is below:

-- >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.c-torture/execute/pr117476.c: New test. From Zhendong Su.

Signed-off-by: Alexey Merzlyakov <alexey.merzlya...@samsung.com>
---
 gcc/simplify-rtx.cc                            |  2 +-
 gcc/testsuite/gcc.c-torture/execute/pr117476.c | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.c-torture/execute/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.c-torture/execute/pr117476.c 
b/gcc/testsuite/gcc.c-torture/execute/pr117476.c
new file mode 100644
index 00000000000..97deb1e2b63
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr117476.c
@@ -0,0 +1,10 @@
+/* PR rtl-optimization/117476 */
+
+int c = 0x1FF;
+
+int main()
+{
+  if (((c ^ 0xFF) & 0xFF) != 0)
+    __builtin_abort();
+  return 0;
+}
-- 
2.34.1



Reply via email to