https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61938
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> --- (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.