http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46032
Summary: openmp inhibits loop vectorization Product: gcc Version: 4.5.1 Status: UNCONFIRMED Severity: major Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: vincenzo.innoce...@cern.ch The use of openmp to parallelize loop inhibits auto-vectorization. This defeats all benefits of parallelization making the parallel code slower than the "sequential one". Is it foreseen a version of openmp that preserve auto-vectorization? Example on Linux 2.6.18-194.11.3.el5.cve20103081 #1 SMP Thu Sep 16 15:17:10 CEST 2010 x86_64 x86_64 x86_64 GNU/Linux using GNU C++ (GCC) version 4.6.0 20100408 (experimental) (x86_64-unknown-linux-gnu) compiled by GNU C version 4.6.0 20100408 (experimental), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 compiling this simple example cat openmpvector.cpp int main() { const unsigned int nEvents = 1000; double results[nEvents] = {0}; double pData[nEvents] = {0}; double coeff = 12.2; #pragma omp parallel for for (int idx = 0; idx<(int)nEvents; idx++) { results[idx] = coeff*pData[idx]; } return resultsCPU[0]; // avoid optimization of "dead" code } gives g++ -O2 -fopenmp -ftree-vectorize -ftree-vectorizer-verbose=7 openmpvector.cpp openmpvector.cpp:11: note: not vectorized: loop contains function calls or data references that cannot be analyzed openmpvector.cpp:9: note: vectorized 0 loops in function.