[gcc r17-3528] match: simplify cond_carry_add and cond_carry_add_neg match by using `:c` [PR126956]
Andrea Pinski via Gcc-cvs <[email protected]>
| Newsgroups | gmane.comp.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://gcc.gnu.org/g:bfd190682ca8e21b66843f5aab180dbdbf9f664c commit r17-3528-gbfd190682ca8e21b66843f5aab180dbdbf9f664c Author: Andrea Pinski <[email protected]> Date: Thu Aug 20 23:51:36 2026 -0700 match: simplify cond_carry_add and cond_carry_add_neg match by using `:c` [PR126956] cond_carry_add and cond_carry_add_neg currently spells out `lt`/`le` and `gt`/`ge` with the operands swapped. We can simplify the pattern as written to make it easier for a developer to only need to change one pattern by using `:c`. Pushed as obvious after a bootstrap/test on x86_64-linux-gnu. Also looked into the generated code from genmatch to see the code is exactly the same as before. PR tree-optimization/126956 gcc/ChangeLog: * match.pd (cond_carry_add): Use `:c` instead of manually swapping the comparison and operands. (cond_carry_add_neg): Likewise. Signed-off-by: Andrea Pinski <[email protected]> Diff: --- gcc/match.pd | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index 9ef2136754c5..ab6e3e4b9f1e 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -6851,13 +6851,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && TYPE_UNSIGNED (type) && type_has_mode_precision_p (type)) (match (cond_carry_add @0 @1 @2 @3) - (cond^ (gt @0 @1) (plus @2 integer_pow2p@3) @2)) - (match (cond_carry_add @0 @1 @2 @3) - (cond^ (lt @1 @0) (plus @2 integer_pow2p@3) @2)) - (match (cond_carry_add_neg @0 @1 @2 @3) - (cond^ (le @0 @1) @2 (plus @2 integer_pow2p@3))) + (cond^ (gt:c @0 @1) (plus @2 integer_pow2p@3) @2)) (match (cond_carry_add_neg @0 @1 @2 @3) - (cond^ (ge @1 @0) @2 (plus @2 integer_pow2p@3)))) + (cond^ (le:c @0 @1) @2 (plus @2 integer_pow2p@3)))) /* (a > 1) ? 0 : (cast)a is the same as (cast)(a == 1) for unsigned types. */