It is obvious that the results of logical-OR and addition of two bitwise
disjoint terms are equal.

gcc/ChangeLog:

        * match.pd ((x & ~m) | (y & m)): Change `bit_ior` to `op`, and then
        modify it so that `op` expands to both `bit_ior` and `plus`.
---
 gcc/match.pd | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gcc/match.pd b/gcc/match.pd
index 4ed058f6e18..d45dd9f8cf6 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -2704,10 +2704,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
       && TYPE_PRECISION (TREE_TYPE (@0)) == 1)
   (convert (bit_xor @0 @1))))
-/* (x & ~m) | (y & m) -> ((x ^ y) & m) ^ x */
-(simplify
- (bit_ior:c (bit_and:cs @0 (bit_not @2)) (bit_and:cs @1 @2))
- (bit_xor (bit_and (bit_xor @0 @1) @2) @0))
+/* (x & ~m) |+ (y & m) -> ((x ^ y) & m) ^ x */
+(for op (bit_ior plus)
+ (simplify
+  (op:c (bit_and:cs @0 (bit_not @2)) (bit_and:cs @1 @2))
+  (bit_xor (bit_and (bit_xor @0 @1) @2) @0)))
/* Fold A - (A & B) into ~B & A. */
 (simplify
--
2.39.5

Reply via email to