https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120356
Alexey Merzlyakov <alexey.merzlyakov at samsung dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |alexey.merzlyakov at samsung dot c | |om --- Comment #4 from Alexey Merzlyakov <alexey.merzlyakov at samsung dot com> --- Confirm the problem appears since https://gcc.gnu.org/cgit/gcc/commit/?id=7b815107f40 and un-hides by https://gcc.gnu.org/cgit/gcc/commit/?id=28b2ad5341f which fixes ICE then. These commits are seem to uncover the issue but are not the cause of the problem. Reduced test-case which does not require -flto to ease debug process: unsigned char a = 5; long long c[18]; static void d () { for (short i = 0; i < 60; i += 65413) for (char j = 0; j < 18; j++) { for (char k = 0; k < 18; k++) { a *= 143; } for (char k = 0; k < 6; k++) for (char l = 0; l < 18; l++) c[l] = 0; } } int main() { d(); __builtin_printf("%llu\n", a + c[0]); } It works on -O2 and above. >From the first sight, it generates the vector calculation chain in the beginning of the function, like this: vid.v v1 li a3,-113 vsll.vi v2,v1,1 vand.vi v1,v1,1 vsll.vi v3,v2,5 vmseq.vi v0,v1,1 vadd.vx v3,v3,a3 li a3,-32 vmul.vx v2,v2,a3 li a3,-31 vadd.vx v2,v2,a3 vmerge.vvm v2,v3,v2,v0 However, compiler inserts it again in the loop body when d() is being inlined, which leads to incorrect "5" result. Further investigations are in progress on it.