https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113268
Bug ID: 113268 Summary: (i + (i + 1) * CST) AND (i + i * CST + 1 * CST) not folded the same way Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: denis.campredon at gmail dot com Target Milestone: --- The two following functions should produce the same assembly with optimizations enabled. This lead, for exemple, to missed optimization with -Oz --------------- #define CST 36 int foo(int i) { return i + (i + 1) * CST; } int bar(int i) { return i + i * CST + 1 * CST; } --------------- foo: lea eax, [rdi+1] imul eax, eax, 36 add eax, edi ret bar: imul eax, edi, 37 add eax, 36 ret