re PR middle-end/25530 ((unsigned / 2)*2 is not changed into unsigned &~1)
authorNaveen H.S <Naveen.Hurugalawadi@caviumnetworks.com>
Fri, 24 Jul 2015 04:50:41 +0000 (04:50 +0000)
committerNaveen H.S <naveenh@gcc.gnu.org>
Fri, 24 Jul 2015 04:50:41 +0000 (04:50 +0000)
PR middle-end/25530
2015-07-24  Naveen H.S  <Naveen.Hurugalawadi@caviumnetworks.com>

gcc/testsuite/ChangeLog:
* gcc.dg/pr25530.c: New test.

gcc/ChangeLog:
* match.pd (mult (trunc_div @0 integer_pow2p@1) @1) : New simplifier.

From-SVN: r226137

gcc/ChangeLog
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr25530.c [new file with mode: 0644]

index aca1f829b76e88bc32b9bc050c748dbf60378cfe..075c0fd4d96f0b87787706e1747feeb385d9c4dd 100644 (file)
@@ -1,3 +1,8 @@
+2015-07-24  Naveen H.S  <Naveen.Hurugalawadi@caviumnetworks.com>
+
+       PR middle-end/25530
+       * match.pd (mult (trunc_div @0 integer_pow2p@1) @1) : New simplifier.
+
 2015-07-24  Naveen H.S  <Naveen.Hurugalawadi@caviumnetworks.com>
 
          PR middle-end/25529
index cc3089753aa2b860d3fce5204a0a694edc2b0c67..2ee36dec1ed212c009741997d622729a7b018177 100644 (file)
@@ -289,6 +289,12 @@ along with GCC; see the file COPYING3.  If not see
                (type, wi::mask (TYPE_PRECISION (type) - wi::exact_log2 (@1),
                                 false, TYPE_PRECISION (type))); })))
 
+/* Simplify (unsigned t / 2) * 2 -> unsigned t & ~1.  */
+(simplify
+ (mult (trunc_div @0 integer_pow2p@1) @1)
+ (if (TYPE_UNSIGNED (TREE_TYPE (@0)))
+  (bit_and @0 (negate @1))))
+
 /* X % Y is smaller than Y.  */
 (for cmp (lt ge)
  (simplify
index 9adf8768165a7c695a14216f5a1ed5a03063776b..7e94b2fe724b27f819b6c7a4382b795b78ee3afa 100644 (file)
@@ -1,3 +1,8 @@
+2015-07-24  Naveen H.S  <Naveen.Hurugalawadi@caviumnetworks.com>
+
+       PR middle-end/25530
+       * gcc.dg/pr25530.c: New test.
+
 2015-07-24  Naveen H.S  <Naveen.Hurugalawadi@caviumnetworks.com>
 
        PR middle-end/25529
diff --git a/gcc/testsuite/gcc.dg/pr25530.c b/gcc/testsuite/gcc.dg/pr25530.c
new file mode 100644 (file)
index 0000000..b846ab3
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-require-effective-target int32 } */
+
+int
+f (unsigned t)
+{
+  return (t / 2) * 2;
+}
+
+/* { dg-final { scan-tree-dump "\& -2" "optimized" } } */