https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117779
Bug ID: 117779 Summary: abs is not removed from a loop Product: gcc Version: 15.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 r, int n){ for(int i=0;i<n;i++) r = __builtin_abs(r); return r; } ``` This really should be optimized to just `n > 0 ? abs(r) : r`. `& 1` works though.