https://gcc.gnu.org/g:cf2fdd51954eccb804759b31fcd3f73c3cd133b4

commit cf2fdd51954eccb804759b31fcd3f73c3cd133b4
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Mon Dec 2 20:48:50 2024 +0100

    Add test.
    
            PR tree-optimization/115494
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/torture/pr115494.c: New test.

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr115494.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/torture/pr115494.c 
b/gcc/testsuite/gcc.dg/torture/pr115494.c
new file mode 100644
index 000000000000..38551c79d0fd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr115494.c
@@ -0,0 +1,25 @@
+/* { dg-do run }
+
+   PR tree-optimization/115494
+   When trying to factor the redundant expression A | B below, the information
+   that B has [0,1] range in the if branch was wrongly used to simplify the
+   factored expression in the true FLAG case.  */
+
+__attribute__((noipa))
+unsigned f(_Bool flag, unsigned b, int a)
+{
+  int x;
+  if (flag)
+    a = 1;
+  if ((b & 1) == b) // b [0,1]
+    x = a | b;
+  else
+    x = a | b;
+  return x;
+}
+
+int main()
+{
+  if (f(1, 3, 3) != 3)
+    __builtin_abort();
+}

Reply via email to