diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2017-06-28 11:22:30 +0200 |
---|---|---|
committer | Marc Glisse <glisse@gcc.gnu.org> | 2017-06-28 09:22:30 +0000 |
commit | 42bd89ce072220f3569cb5e761235dcf1c675c68 (patch) | |
tree | 5fb4ca44d3407af3a15cbc4392d4ebc6933067b7 /gcc/match.pd | |
parent | 883312dc79806f513275b72502231c751c14ff72 (diff) | |
download | gcc-42bd89ce072220f3569cb5e761235dcf1c675c68.zip gcc-42bd89ce072220f3569cb5e761235dcf1c675c68.tar.gz gcc-42bd89ce072220f3569cb5e761235dcf1c675c68.tar.bz2 |
Simplify 3*x == 3*y for wrapping types
2017-06-28 Marc Glisse <marc.glisse@inria.fr>
gcc/
* match.pd ((X & ~Y) | (~X & Y)): Generalize to + and ^.
(x * C EQ/NE y * C): New transformation.
gcc/testsuite/
* gcc.dg/tree-ssa/addadd.c: Remove test duplicated in addadd-2.c.
* gcc.dg/tree-ssa/mulcmp-1.c: New file.
From-SVN: r249732
Diffstat (limited to 'gcc/match.pd')
-rw-r--r-- | gcc/match.pd | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index c132cba..ede5504 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -642,14 +642,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (minus (bit_and:cs @0 @1) (bit_and:cs @0 (bit_not @1))) (minus @1 (bit_xor @0 @1))) -/* Simplify (X & ~Y) | (~X & Y) -> X ^ Y. */ -(simplify - (bit_ior (bit_and:c @0 (bit_not @1)) (bit_and:c (bit_not @0) @1)) - (bit_xor @0 @1)) -(simplify - (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))) +/* Simplify (X & ~Y) |^+ (~X & Y) -> X ^ Y. */ +(for op (bit_ior bit_xor plus) + (simplify + (op (bit_and:c @0 (bit_not @1)) (bit_and:c (bit_not @0) @1)) + (bit_xor @0 @1)) + (simplify + (op: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 @@ -1097,6 +1098,16 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && tree_expr_nonzero_p (@1)) (cmp @0 @2)))) +/* For integral types with wrapping overflow and C odd fold + x * C EQ/NE y * C into x EQ/NE y. */ +(for cmp (eq ne) + (simplify + (cmp (mult @0 INTEGER_CST@1) (mult @2 @1)) + (if (INTEGRAL_TYPE_P (TREE_TYPE (@1)) + && TYPE_OVERFLOW_WRAPS (TREE_TYPE (@0)) + && (TREE_INT_CST_LOW (@1) & 1) != 0) + (cmp @0 @2)))) + /* For integral types with undefined overflow and C != 0 fold x * C RELOP y * C into: |