https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128123
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrea Pinski <[email protected]>: https://gcc.gnu.org/g:c13a1b09d938e86b9e9c18588457582cb016087c commit r17-5591-gc13a1b09d938e86b9e9c18588457582cb016087c Author: Andrea Pinski <[email protected]> Date: Sat Oct 24 12:03:16 2026 -0700 match/fold: Fix combine_comparisons for vector(signed) boolean types [PR128123] r17-4001-gbbc2517fe41 added support to combine_comparisons for LT/LE/GT/GE but it assumed unsigned boolean types ([0,1]) which is wrong for signed boolean types ([0,-1]). For an example, for signed boolean types, LT is the same as GT for unsigned boolean types. So this was combining incorrectly and getting the incorrect answer. This fixes the problem by adding support for signed boolean. Since we need to pass in a new argument to combine_comparisons, this updates all of the uses of combine_comparisons which makes the patch look bigger than it really is. Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR tree-optimization/128123 gcc/ChangeLog: * fold-const.cc (combine_comparisons): Take new argument, inner_truth_type and look to see if it is signed boolean and support that for LT/LE/GT/GE. (fold_truth_andor_1): Update call to combine_comparisons. * fold-const.h (combine_comparisons): Add new argument. * gimple-fold.cc (and_comparisons_1): Update call to combine_comparisons. (or_comparisons_1): Likewise. * tree-ssa-ifcombine.cc (ifcombine_ifandif): Likewise. * tree-ssa-phiopt.cc (comparison_combine): Likewise. * match.pd (`(CMP) OP (CMP)`): Update call to combine_comparisons. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/vect-cmp-cmp-1.c: New test. Signed-off-by: Andrea Pinski <[email protected]>
