re PR middle-end/25530 ((unsigned / 2)*2 is not changed into unsigned &~1)

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
This commit is contained in:
Naveen H.S 2015-07-24 04:50:41 +00:00 committed by Naveen H.S
parent 887ab60965
commit 5f8d832e47
4 changed files with 27 additions and 0 deletions

View 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

View 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

View 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

View File

@ -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" } } */