https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87914
Bug ID: 87914 Summary: gcc fails to vectorize bitreverse code Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: hoganmeier at gmail dot com Target Milestone: --- $ gcc -fopenmp-simd -O3 -march=haswell -fopt-info-vec-omp-optimized-missed template <typename T> T reverseBits(T x) { unsigned int s = sizeof(x) * 8; T mask = ~T(0); while ((s >>= 1) > 0) { mask ^= (mask << s); x = ((x >> s) & mask) | ((x << s) & ~mask); // unsupported use in stmt } return x; } void test_reverseBits(unsigned* x) { #pragma omp simd aligned(x:32) for (int i = 0; i < 16; ++i) x[i] = reverseBits(x[i]); // couldn't vectorize loop } clang and icc vectorize this: https://godbolt.org/z/ROJZGZ