diff options
author | Andrew Pinski <quic_apinski@quicinc.com> | 2023-12-24 15:51:35 -0800 |
---|---|---|
committer | Andrew Pinski <quic_apinski@quicinc.com> | 2023-12-24 20:01:32 -0800 |
commit | 59ecd5ff096f800de17b804f1482055f2d84d629 (patch) | |
tree | 986d00ae3ea2571edf47980aefdb7af18e025c4a /gcc/match.pd | |
parent | f0269df25af37097a06ae247a18c71e24aa32e3e (diff) | |
download | gcc-59ecd5ff096f800de17b804f1482055f2d84d629.zip gcc-59ecd5ff096f800de17b804f1482055f2d84d629.tar.gz gcc-59ecd5ff096f800de17b804f1482055f2d84d629.tar.bz2 |
match: Improve `(a != b) ? (a + b) : (2 * a)` pattern [PR19832]
In the testcase provided, we would match f_plus but not g_plus
due to a missing `:c` on the plus operator. This fixes the oversight
there.
Note this was noted in https://github.com/llvm/llvm-project/issues/76318 .
Committed as obvious after bootstrap/test on x86_64-linux-gnu.
PR tree-optimization/19832
gcc/ChangeLog:
* match.pd (`(a != b) ? (a + b) : (2 * a)`): Add `:c`
on the plus operator.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/phi-opt-same-2.c: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Diffstat (limited to 'gcc/match.pd')
-rw-r--r-- | gcc/match.pd | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index d57e29b..a980c4d 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -5694,7 +5694,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) @2))) /* (a != b) ? (a + b) : (2 * a) -> (a + b) */ (simplify - (cnd (ne:c @0 @1) (plus@2 @0 @1) (mult @0 uniform_integer_cst_p@3)) + (cnd (ne:c @0 @1) (plus:c@2 @0 @1) (mult @0 uniform_integer_cst_p@3)) (if (wi::to_wide (uniform_integer_cst_p (@3)) == 2) @2)) ) |