[Bug tree-optimization/61938] Vectorization not happening .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61938 Marek Polacek changed: What|Removed |Added Status|WAITING |RESOLVED Resolution|--- |INVALID --- Comment #8 from Marek Polacek --- Nothing to do here.
[Bug tree-optimization/61938] Vectorization not happening .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61938 --- Comment #7 from Richard Biener --- (In reply to harmeeksingh from comment #6) > > Equivalent code when written by hand where tmp is a intermediate array . The > compiler > vectorizes both loops. > > int k, i; > /* vectorize the compares */ > for (i=0; i < arraysize; ++i) { >tmp[i] = (array[i] == compval); > } > > /* another loop now set the result array */ > for (k=0, i=0; i < arraysize; ++i) { > if (tmp[i]) > { >result[k] = i; >k++; > } > } I only see the first loop vectorized. typedef long int int64; typedef int int32; void foo (int arraysize, int *__restrict result, int *__restrict tmp, int *__restrict selectvector, int selectelements, int64 *__restrict array, int64 compval) { int k, i; /* another loop now set the result array */ for (k=0, i=0; i < arraysize; ++i) { if (tmp[i]) { result[k] = i; k++; } } } cannot be vectorized exactly because of the said reasons.
[Bug tree-optimization/61938] Vectorization not happening .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61938 --- Comment #6 from harmeeksingh at gmail dot com --- Equivalent code when written by hand where tmp is a intermediate array . The compiler vectorizes both loops. int k, i; /* vectorize the compares */ for (i=0; i < arraysize; ++i) { tmp[i] = (array[i] == compval); } /* another loop now set the result array */ for (k=0, i=0; i < arraysize; ++i) { if (tmp[i]) { result[k] = i; k++; } }
[Bug tree-optimization/61938] Vectorization not happening .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61938 --- Comment #5 from Richard Biener --- The test from comment #3 has exactly the same issue - the store to result[k] cannot be vectorized in any meaningful way.
[Bug tree-optimization/61938] Vectorization not happening .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61938 --- Comment #4 from Marc Glisse --- Please show what you would like the code to look like after vectorization.
[Bug tree-optimization/61938] Vectorization not happening .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61938 --- Comment #3 from harmeeksingh at gmail dot com --- #include #define VEC 1024 typedef long int int64; typedef int int32; void foo (int arraysize, int *__restrict result, int *__restrict selectvector, int selectelements, int64 *__restrict array, int64 compval) { int k, i; for (k =0,i=0; i < arraysize; ++i) { result[k] = i; k += (array[i] == compval); } } main() { int result[VEC]; int selectvector[VEC]; int selectelements; int64 array[VEC]; int k, i; foo(VEC, result, selectvector, VEC, array, 1); } Even the above does not vectorize gcc -fPIC -shared -DCLS=64 -ffast-math -mfpmath=sse -mmmx -msse -msse2 -ftree-vectorize -ftree-vectorizer-verbose=7 -O3 -march=native /tmp/x.c -o /tmp/x Analyzing loop at /tmp/x.c:17 17: not vectorized: data ref analysis failed *D.2502_9 = i_27; /tmp/x.c:9: note: vectorized 0 loops in function.
[Bug tree-optimization/61938] Vectorization not happening .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61938 Richard Biener changed: What|Removed |Added Status|UNCONFIRMED |WAITING Last reconfirmed||2014-07-29 Ever confirmed|0 |1 --- Comment #2 from Richard Biener --- The issue is the store to result[k] where k is not an affine induction variable. This is a "distribute" store (similar to a "gather" load). I see no sensible way of vectorizing this, do you?
[Bug tree-optimization/61938] Vectorization not happening .
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61938 --- Comment #1 from Andrew Pinski --- array[selectvector[i]] is not handled.