From: Kael Andrew Alonzo Franco Date: Tue, 28 Jul 2026 16:37:18 +0000 (-0400) Subject: match: Combine patterns into five for. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a73b5e72fa52289d8dd718edd10047c822c0c6cd;p=thirdparty%2Fgcc.git match: Combine patterns into five for. This merges 10 simplify patterns so genmatch outputs less C++ code. Bootstrapped and regtested on x86_64-pc-linux-gnu. gcc/ChangeLog: * match.pd: Combine patterns into five for. Signed-off-by: Kael Andrew Franco --- diff --git a/gcc/match.pd b/gcc/match.pd index 62d08093125..f6ecee41509 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1655,15 +1655,13 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && (!wascmp || element_precision (type) == 1)) @0))) -/* ~(~a & b) --> a | ~b */ -(simplify - (bit_not (bit_and:cs (bit_not @0) @1)) - (bit_ior @0 (bit_not @1))) - -/* ~(~a | b) --> a & ~b */ -(simplify - (bit_not (bit_ior:cs (bit_not @0) @1)) - (bit_and @0 (bit_not @1))) +/* ~(~a & b) --> a | ~b + ~(~a | b) --> a & ~b */ +(for iop (bit_and bit_ior) + res (bit_ior bit_and) + (simplify + (bit_not (iop:cs (bit_not @0) @1)) + (res @0 (bit_not @1)))) /* (a ^ b) & ((b ^ c) ^ a) --> (a ^ b) & ~c */ (simplify @@ -1928,30 +1926,26 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (bit_xor:c (bit_ior:c @0 @1) (bit_ior:c @0 (bit_not @1))) (bit_not @0)) -/* (x & y) | ~(x | y) -> ~(x ^ y) */ -(simplify - (bit_ior:c (bit_and:s @0 @1) (bit_not:s (bit_ior:s @0 @1))) - (bit_not (bit_xor @0 @1))) +/* (x & y) | ~(x | y) -> ~(x ^ y) + (x ^ y) | ~(x | y) -> ~(x & y) */ +(for lop (bit_and bit_xor) + res (bit_xor bit_and) + (simplify + (bit_ior:c (lop:s @0 @1) (bit_not:s (bit_ior:s @0 @1))) + (bit_not (res @0 @1)))) /* (~x | y) ^ (x ^ y) -> x | ~y */ (simplify (bit_xor:c (bit_ior:cs (bit_not @0) @1) (bit_xor:s @0 @1)) (bit_ior @0 (bit_not @1))) -/* (x ^ y) | ~(x | y) -> ~(x & y) */ -(simplify - (bit_ior:c (bit_xor:s @0 @1) (bit_not:s (bit_ior:s @0 @1))) - (bit_not (bit_and @0 @1))) - -/* (x & y) ^ (x | y) -> x ^ y */ -(simplify - (bit_xor:c (bit_and @0 @1) (bit_ior @0 @1)) - (bit_xor @0 @1)) - -/* (x ^ y) ^ (x | y) -> x & y */ -(simplify - (bit_xor:c (bit_xor @0 @1) (bit_ior @0 @1)) - (bit_and @0 @1)) +/* (x & y) ^ (x | y) -> x ^ y + (x ^ y) ^ (x | y) -> x & y */ +(for lop (bit_and bit_xor) + res (bit_xor bit_and) + (simplify + (bit_xor:c (lop @0 @1) (bit_ior @0 @1)) + (res @0 @1))) /* (x & y) + (x ^ y) -> x | y */ /* (x & y) | (x ^ y) -> x | y */ @@ -1966,34 +1960,28 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (plus:c (bit_and @0 @1) (bit_ior @0 @1)) (plus @0 @1)) -/* (x + y) - (x | y) -> x & y */ -(simplify - (minus (plus @0 @1) (bit_ior @0 @1)) - (if (!TYPE_OVERFLOW_SANITIZED (type) && !TYPE_OVERFLOW_TRAPS (type) - && !TYPE_SATURATING (type)) - (bit_and @0 @1))) - -/* (x + y) - (x & y) -> x | y */ -(simplify - (minus (plus @0 @1) (bit_and @0 @1)) - (if (!TYPE_OVERFLOW_SANITIZED (type) && !TYPE_OVERFLOW_TRAPS (type) - && !TYPE_SATURATING (type)) - (bit_ior @0 @1))) +/* (x + y) - (x | y) -> x & y + (x + y) - (x & y) -> x | y */ +(for rop (bit_ior bit_and) + res (bit_and bit_ior) + (simplify + (minus (plus @0 @1) (rop @0 @1)) + (if (!TYPE_OVERFLOW_SANITIZED (type) && !TYPE_OVERFLOW_TRAPS (type) + && !TYPE_SATURATING (type)) + (res @0 @1)))) /* (x | y) - y -> (x & ~y) */ (simplify (minus (bit_ior:cs @0 @1) @1) (bit_and @0 (bit_not @1))) -/* (x | y) - (x ^ y) -> x & y */ -(simplify - (minus (bit_ior @0 @1) (bit_xor @0 @1)) - (bit_and @0 @1)) - -/* (x | y) - (x & y) -> x ^ y */ -(simplify - (minus (bit_ior @0 @1) (bit_and @0 @1)) - (bit_xor @0 @1)) +/* (x | y) - (x ^ y) -> x & y + (x | y) - (x & y) -> x ^ y */ +(for rop (bit_xor bit_and) + res (bit_and bit_xor) + (simplify + (minus (bit_ior @0 @1) (rop @0 @1)) + (res @0 @1))) /* (x | y) & ~(x & y) -> x ^ y */ (simplify