https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70193
Bug ID: 70193 Summary: missed loop splitting support based on iteration space Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vekumar at gcc dot gnu.org Target Milestone: --- Following the comments in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70103#c2 and discussion with Richard, filing this PR. This is inspired by the loop flux_lam.f:68:0 at bwaves which has % operation. int a[100],b[100]; void test(int x, int N1) { int i,im1; for (i=0;i<N1;i++) { im1 = (i-1)%N1 ; b[i] =(a[im1]-a[i]); } } Try to split the iteration space into two and cases where no wraparound happens can be vectorized. int a[100],b[100]; void test(int x, int N1) { int i,im1; for (i=0;i<1;i++) { im1 = (i-1)%N1 ; b[i] =(a[im1]-a[i]); } for (i=1;i<N1;i++) { im1 = (i-1); b[i] =(a[im1]-a[i]);<== loop can be vectorized } }