This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/18412] New: missed vectorization opportunity
- From: "senor_fjord at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Nov 2004 01:03:27 -0000
- Subject: [Bug tree-optimization/18412] New: missed vectorization opportunity
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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