re PR tree-optimization/53979 (((a ^ b) | a) not optimized to (a | b))
authorPrathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
Thu, 20 Oct 2016 07:55:28 +0000 (07:55 +0000)
committerPrathamesh Kulkarni <prathamesh3492@gcc.gnu.org>
Thu, 20 Oct 2016 07:55:28 +0000 (07:55 +0000)
2016-10-20  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

PR tree-optimization/53979
* match.pd ((a ^ b) | a -> a | b): New pattern.

testsuite/
* gcc.dg/pr53979-1.c: New test-case.
* gcc.dg/pr53979-2.c: Likewise.

From-SVN: r241360

gcc/ChangeLog
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr53979-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr53979-2.c [new file with mode: 0644]

index 2b26a38ba9edd26ee7262f8053f604a42609d16a..d4779690e9eb7d97f02d6e8e7a12b37badf54960 100644 (file)
@@ -1,3 +1,8 @@
+2016-10-20  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
+
+       PR tree-optimization/53979
+       * match.pd ((a ^ b) | a -> a | b): New pattern.
+
 2016-10-19  John David Anglin  <danglin@gcc.gnu.org>
 
        * config/pa/pa64-hpux.h (PA_INIT_FRAME_DUMMY_ASM_OP): Move to
index b782a1ed2f4d5297f17037bd973644567e5c72c6..78884591c8fba331544431351495253480abdb42 100644 (file)
@@ -541,6 +541,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  (bit_ior:c (bit_and @0 INTEGER_CST@2) (bit_and (bit_not @0) INTEGER_CST@1))
  (if (wi::bit_not (@2) == @1)
   (bit_xor @0 @1)))
+
+/* PR53979: Transform ((a ^ b) | a) -> (a | b) */
+(simplify
+  (bit_ior:c (bit_xor:c @0 @1) @0)
+  (bit_ior @0 @1))
+
 /* Simplify (~X & Y) to X ^ Y if we know that (X & ~Y) is 0.  */
 #if GIMPLE
 (simplify
index 8f5230f515ab7b5ba7e2088f51184247ae7d6e69..152b1b26bbaf673c284889c73ade64c207d56e43 100644 (file)
@@ -1,3 +1,9 @@
+2016-10-20  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
+
+       PR tree-optimization/53979
+       * gcc.dg/pr53979-1.c: New test-case.
+       * gcc.dg/pr53979-2.c: Likewise.
+
 2016-10-19  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        * c-c++-common/Wint-in-bool-context-2.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr53979-1.c b/gcc/testsuite/gcc.dg/pr53979-1.c
new file mode 100644 (file)
index 0000000..aee54f5
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-gimple" } */
+
+unsigned f1(unsigned a, unsigned b)
+{
+  return (a ^ b) | a; 
+}
+
+/* { dg-final { scan-tree-dump "a | b" "gimple" } } */
diff --git a/gcc/testsuite/gcc.dg/pr53979-2.c b/gcc/testsuite/gcc.dg/pr53979-2.c
new file mode 100644 (file)
index 0000000..be2607a
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-forwprop-details" } */
+
+unsigned f(unsigned a, unsigned b)
+{
+  unsigned t1 = a ^ b;
+  unsigned t2 = t1 | a;
+  return t2;
+}
+
+/* { dg-final { scan-tree-dump "gimple_simplified to t2_\[0-9\] = a_\[0-9\]*\\(D\\) | b_\[0-9\]*\\(D\\)" "forwprop1" } } */