gnu/gcc/8f6eb7077059952273cc39de66e1dca01b84cb4d match: Fix `a CMP CST0 ? MIN/MAX<a, b> : MIN/MAX<a, CST1>` pattern [PR126456]
The order of the arguments for minmax_from_comparison is wrong for this
pattern. I swapped the 2 CST which in some cases could cause
incorrect code.
Pushed as obvious after a bootstrap/testing on x86_64-linux-gnu.
Note for backporting, minmax-29.c and minmax-30.c will need to be
changed slightly because we don't factor out the min/max before GCC 17.
PR tree-optimization/126456
gcc/ChangeLog:
* match.pd (`a CMP b ? MIN/MAX<a, c> : MIN/MAX<a, d>`): Fix
order of minmax_from_comparison arguments.
gcc/testsuite/ChangeLog:
* gcc.dg/torture/minmax-1.c: New test.
* gcc.dg/tree-ssa/minmax-29.c: New test.
* gcc.dg/tree-ssa/minmax-30.c: New test.
* gcc.dg/tree-ssa/minmax-31.c: New test.
* gcc.dg/tree-ssa/minmax-32.c: New test.
Signed-off-by: Andrea Pinski <andrew.pinski@oss.qualcomm.com>
6 files changed