https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125791
Bug ID: 125791
Summary: match's ifcvt should only happen after the last fold
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: internal-improvement, missed-optimization
Severity: enhancement
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Patterns like:
/* (zero_one == 0) ? y : z <op> y -> ((typeof(y))zero_one * z) <op> y */
/* (zero_one != 0) ? z <op> y : y -> ((typeof(y))zero_one * z) <op> y */
/* a ? 0 : powerof2cst -> (!a) << (log2(powerof2cst)) */
/* PR123967: if (cond) A | CST1 : A & ~CST1
Make both bitops unconditional: (A & ~CST1) | (cond * CST1). */
Maybe even:
/* Try to optimize x < 0 ? -1 : 0 into (signed) x >> 31
and x < 0 ? 1 : 0 into (unsigned) x >> 31. */
(or changed to be `(x<0)`[0,1] or `-(x<0)`[0,-1])
All should be done after the last fold PROP is set.
Or maybe even during expand.
This is from https://gcc.gnu.org/pipermail/gcc/2026-June/248292.html (and other
discussions about this).