https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116008
Bug ID: 116008 Summary: MAX<i+j, i+k> should simplify to MAX<j,k>+i 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: --- I noticed this while reading PR 102951 and seeing what can be done better. Take: ``` int g(int i, int j, int k) { int t = i+j; int t1 = i+k; return t > t1; } int f(int i, int j, int k) { int t = i+j; int t1 = i+k; return t > t1 ? t : t1; } int f1(int i, int j, int k) { int t = i+j; int t1 = i+k; return i+(t > t1 ? j : k); } ``` We can optimize just find g to `j > k`; but f does not get optimized to f1.