https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103116
Bug ID: 103116 Summary: SLP vectoriser fails to peel for gaps Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rsandifo at gcc dot gnu.org CC: rguenth at gcc dot gnu.org Target Milestone: --- Created attachment 51744 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51744&action=edit testcase Compiling the attached testcase on x86_64-linux-gnu with -O2 -fno-vect-cost-model triggers a segfault. We implement the y[] reads in: for (int i = 0; i < COUNT; ++i) { x[i * 4] = y[i * 2] + 1; x[i * 4 + 1] = y[i * 2] + 2; x[i * 4 + 2] = y[i * 2 + 1] + 3; x[i * 4 + 3] = y[i * 2 + 1] + 4; } using a load and permute in which only the low half of the loaded data is used. The high half of the final iteration overruns the array. I guess the usual approach of peeling one iteration for gaps will be enough, but haven't thought about it much. Are there corner cases where we might need to peel more? (We get away with this on AArch64 because we fall back to load/store lanes instead.)