https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114213
Bug ID: 114213 Summary: `MIN<MAX<a,-CST>, CST> / CST` -> `a >= CST ? 1 : -(a <= -CST)` Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: 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: --- Take: ``` int f(int a) { a = a <= -64 ? -64 : a; a = a >= 64 ? 64 : a; return a/64; } int f1(int a) { return a >= 64 ? 1 : -(a <= -64); } int f2(int a) { return a <= -64 ? -1 : (a >= 64); } ``` These all three should produce the same result. This is basically the expanded version of PR 114212 on to the negative side.