x & C -> x if we know that x & ~C == 0
2016-05-17 Marc Glisse <marc.glisse@inria.fr> gcc/ * match.pd (X & C): New transformation. gcc/testsuite/ * gcc.dg/tree-ssa/and-1.c: New testcase. From-SVN: r236338
This commit is contained in:
parent
d982c5b7b7
commit
c7986356a1
4 changed files with 28 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
|||
2016-05-17 Marc Glisse <marc.glisse@inria.fr>
|
||||
|
||||
* match.pd (X & C): New transformation.
|
||||
|
||||
2016-05-17 Marc Glisse <marc.glisse@inria.fr>
|
||||
|
||||
* match.pd (~X & Y): New transformation.
|
||||
|
|
|
@ -563,6 +563,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
|
|||
(bitop @0 @0)
|
||||
(non_lvalue @0)))
|
||||
|
||||
/* x & C -> x if we know that x & ~C == 0. */
|
||||
#if GIMPLE
|
||||
(simplify
|
||||
(bit_and SSA_NAME@0 INTEGER_CST@1)
|
||||
(if (INTEGRAL_TYPE_P (TREE_TYPE (@0))
|
||||
&& (get_nonzero_bits (@0) & wi::bit_not (@1)) == 0)
|
||||
@0))
|
||||
#endif
|
||||
|
||||
/* x + (x & 1) -> (x + 1) & ~1 */
|
||||
(simplify
|
||||
(plus:c @0 (bit_and:s @0 integer_onep@1))
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2016-05-17 Marc Glisse <marc.glisse@inria.fr>
|
||||
|
||||
* gcc.dg/tree-ssa/and-1.c: New testcase.
|
||||
|
||||
2016-05-17 Marc Glisse <marc.glisse@inria.fr>
|
||||
|
||||
* gcc.dg/tree-ssa/pr69270.c: Adjust.
|
||||
|
|
11
gcc/testsuite/gcc.dg/tree-ssa/and-1.c
Normal file
11
gcc/testsuite/gcc.dg/tree-ssa/and-1.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-O -fdump-tree-optimized-raw" } */
|
||||
|
||||
int f(int in) {
|
||||
in = in | 3;
|
||||
in = in ^ 1;
|
||||
in = (in & ~(unsigned long)1);
|
||||
return in;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-tree-dump-not "bit_and_expr" "optimized" } } */
|
Loading…
Add table
Reference in a new issue