https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128588
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Kyrylo Tkachov <[email protected]>: https://gcc.gnu.org/g:29413f3786a0c83e29f649568ae94017961b9f30 commit r17-6350-g29413f3786a0c83e29f649568ae94017961b9f30 Author: Kyrylo Tkachov <[email protected]> Date: Thu Nov 12 01:50:56 2026 -0800 if-to-switch: Do not merge IORs of anti-ranges [PR128588] find_conditions handles "_3 = a | b; if (_3 != 0)" by recording one range per IOR operand. It checks that both operands test the same SSA name with the same IN_P flag. When IN_P is false, both operands are anti-ranges and (x not in R1) | (x not in R2) is the complement of the intersection of R1 and R2, not of their union. The pass takes the false edge as the switch target and emits one case label per range, so the labels cover the union and some values reach the wrong edge. For _Bool a = (unsigned) x - 113u > 2u; _Bool b = x != 120; if (a | b) return 8; return 9; the condition is true for every x, but the generated switch has case 113 ... 115 and case 120 going to the "return 9" block. Only accept an IOR of several ranges when the ranges are IN_P. Bootstrapped and tested on aarch64-none-linux-gnu. gcc/ChangeLog: PR tree-optimization/128588 * gimple-if-to-switch.cc (find_conditions): Reject an IOR of anti-ranges. gcc/testsuite/ChangeLog: PR tree-optimization/128588 * gcc.dg/torture/pr128588.c: New test. Signed-off-by: Kyrylo Tkachov <[email protected]>
