https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111957
Bug ID: 111957 Summary: `a ? abs(a) : 0` is not simplified to just abs(a) Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: pinskia at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` int f(int a) { if (a) return a > 0 ? a : -a; return 0; } ``` This should just simplify to ` return a > 0 ? a : -a;` or rather `return abs(a);`