https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111894
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Blocks| |53947 Last reconfirmed| |2023-10-23 Status|UNCONFIRMED |NEW Ever confirmed|0 |1 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed. Creating dr for MEM <struct array> [(value_type &)&data]._M_elems[_7]._M_elems[_8] analyze_innermost: t.C:23:24: missed: failed: evolution of offset is not affine. we have void init2 () { long unsigned int SR.100; long unsigned int ivtmp_1; long unsigned int _4; long unsigned int ivtmp_6; long unsigned int _7; long unsigned int _8; <bb 2> [local count: 10737416]: <bb 3> [local count: 1063004409]: # SR.100_13 = PHI <_4(5), 0(2)> # ivtmp_6 = PHI <ivtmp_1(5), 400(2)> _7 = SR.100_13 / 20; _8 = SR.100_13 % 20; MEM <struct array> [(value_type &)&data]._M_elems[_7]._M_elems[_8] = 123; _4 = SR.100_13 + 1; ivtmp_1 = ivtmp_6 - 1; if (ivtmp_1 != 0) goto <bb 5>; [99.00%] else goto <bb 4>; [1.00%] <bb 5> [local count: 1052374367]: goto <bb 3>; [100.00%] <bb 4> [local count: 10737416]: return; and the issue is the use of division/modulo for the array accesses, that is, that this C++ idiom results in a "flattened" loop instead of a nest of level two. GCC doesn't support "un-flattening" this. In general, when we can see that the number of iterations is so that unrolling the loop by VF will not cross dimensions we might be able to apply regular loop vectorization but we currently do not have code doing that. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947 [Bug 53947] [meta-bug] vectorizer missed-optimizations