in the following code, first function is vectorized, while the second one is not: typedef float aligned_float __attribute__((aligned(4 * sizeof(float)))); typedef aligned_float * __restrict__ restricted_float_ptr; void test(int n, restricted_float_ptr in, restricted_float_ptr out) { for (int i = 0; i != n; ++i) out[i] = in[i] + 1.f; } void test2(int n, aligned_float * inarg, aligned_float * outarg) { restricted_float_ptr in = inarg; restricted_float_ptr out = outarg; for (int i = 0; i != n; ++i) out[i] = in[i] + 1.f; }
I think this is the same issue as PR 16306.
Link to vectorizer missed-optimization meta-bug.
Both loops are vectorized now, the one in test2 with a runtime check for alias though. Fixed. Link to restrict meta-bug.