https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110428
--- Comment #4 from JuzheZhong <juzhe.zhong at rivai dot ai> --- (In reply to JuzheZhong from comment #3) > Hi, I think for VLS vectors, we should be able the enhance CSE for this > following case: > > #include <stdint.h> > > void __attribute__((noinline,noclone)) > foo (int *out, int *res, unsigned int n) > { > int mask[] = { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 }; > int i; > for (i = 0; i < n+16; ++i) > { > if (mask[i]) > out[i] = i; > } > int o0 = out[0]; > int o7 = out[7]; > int o14 = out[14]; > int o15 = out[15]; > res[0] = o0; > res[2] = o7; > res[4] = o14; > res[6] = o15; > } > > since n is unsigned int number, i < n + 16, ARM SVE fail to CSE. > Is it right? Maybe this case is too complicated, I try this following case: void __attribute__((noinline,noclone)) foo (int *out, int *res, unsigned int n) { int mask[] = { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 }; int i; for (i = 0; i < 16; ++i) { if (mask[i]) out[i] = i; } for (i = 16; i < n + 16; ++i) { if (mask[i]) out[i] = i; } int o0 = out[0]; int o7 = out[7]; int o14 = out[14]; int o15 = out[15]; res[0] = o0; res[2] = o7; res[4] = o14; res[6] = o15; } Such case is simpler, it should be CSE? I tried on SVE, GCC failed to CSE.