https://llvm.org/bugs/show_bug.cgi?id=27625
Bug ID: 27625 Summary: clang loop vectorizer doesn't work when reduction variable is a slot in an array Product: clang Version: 3.8 Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: -New Bugs Assignee: unassignedclangb...@nondot.org Reporter: albertnet...@gmail.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified ``` #define SIZE (1 << 15) #define XMM_ALIGNMENT_BYTES 16 float *vec_a __attribute__((aligned (XMM_ALIGNMENT_BYTES))); float *vec_b __attribute__((aligned (XMM_ALIGNMENT_BYTES))); float *vec_c __attribute__((aligned (XMM_ALIGNMENT_BYTES))); void matvec_autovec() { int i, j; for (i = 0; i < SIZE; i++) { for (j = 0; j < SIZE; j++) { vec_c[i] += vec_a[j] * vec_b[j]; } } } ``` Command used: `clang-3.8 -c -S -Ofast -Rpass-analysis=loop-vectorize test.c` ``` test.c:17:22: remark: loop not vectorized: value that could not be identified as reduction is used outside the loop [-Rpass-analysis=loop-vectorize] vec_c[i] += vec_a[j] * vec_b[j];``` ``` I was expecting that `vec_c[i]` to be treated as inner loop invariant and the vectorization would work. The auto-vectorization works fine if I use a tmp variable for accumulation. Could someone explain why the vectorizer bails out in this case? -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs