https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81082
Bug ID: 81082 Summary: [7 Regression] Failure to vectorise after reassociating index computation Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rsandifo at gcc dot gnu.org Target Milestone: --- After the fix for PR66313 (r248771), we no longer vectorise: int f (int *x, int b1, int b2, int b3) { int foo = 0; for (int i1 = 0; i1 < b1; ++i1) for (int i2 = 0; i2 < b2; ++i2) for (int i3 = 0; i3 < b3; ++i3) foo += x[i1 * b2 * b3 + i2 * b3 + (i3 - 1)]; return foo; } We now convert all the arithmetic in the [...] to unsigned int and reassociate it so that the "- 1" is applied last. We then assume that the overflow in this subtraction is well-defined and that the &x[...] might not be linear for the inner loop.