I'm not sure if this is a missed case or is just not yet implemented. I'm using gcc 4.0.0 20041108 with -O3 -ftree-vectorize -fdump-tree-vect-stats -march=pentium4 -g -ggdb:
the following *is* vectorizable: #include <stdio.h> #include <malloc.h> void foo(int n, int *x) { for (int i = 0; i < n; i++) x[i] = 7; } int main() { int size; int *x; scanf("%d", &size); x = (int *)malloc(sizeof(int) * size); foo(size, x); return 0; } If I manually inline foo as follows, it is *not* vectorized (number of iterations cannot be computed). #include <stdio.h> #include <malloc.h> int main() { int size; int *x; scanf("%d", &size); x = (int *)malloc(sizeof(int) * size); for (int i = 0; i < size; i++) x[i] = 7; return 0; } I'm assuming this is because size has its address taken and throws it off. It just seems like non-intuitive behavior, particularly since gcc ends up inlining the vectorized function for the first code fragment anyhow. -- Summary: missed vectorization opportunity Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: senor_fjord at yahoo dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18412