https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111456
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Last reconfirmed| |2023-09-18 Status|UNCONFIRMED |ASSIGNED Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I noticed a few missed optimizations: <bb 2> [local count: 1073741824]: i.0_1 = i; _2 = (short int) i.0_1; _14 = _2 >= 0; _15 = i.0_1 == 0; _16 = _14 & _15; if (_16 != 0) goto <bb 7>; [50.00%] else goto <bb 3>; [50.00%] <bb 3> [local count: 805306368]: _21 = (int) _2; _20 = _21 == 0; _29 = _21 > 1; _30 = _20 | _29; if (_30 != 0) goto <bb 7>; [72.67%] else goto <bb 4>; [27.33%] Here this should have been just if (i.0_1 == 0) goto <bb 7>; [50.00%] else goto <bb 3>; [50.00%] And that would fix the rest. I suspect if we extend: /* Convert (X == CST1) && (X OP2 CST2) to a known value based on CST1 OP2 CST2. Similarly for (X != CST1). */ /* Convert (X == Y) && (X OP2 Y) to a known value if X is an integral type. Similarly for (X != Y). */ to handle a cast for the second part. This will be fixed ... Will handle that this weekend or earlier.