https://bugs.llvm.org/show_bug.cgi?id=46070
Bug ID: 46070
Summary: The vectorization of the inner loop stops when "#
pragma omp parallel for" is written on the outer loop.
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Loop Optimizer
Assignee: unassignedb...@nondot.org
Reporter: fj876...@aa.jp.fujitsu.com
CC: llvm-bugs@lists.llvm.org
If you write "# pragma omp parallel for" on the outer loop, the vectorization
of the inner loop stops.
If you don't add -fopenmp, vectorization will work.
It is the same with -O3.
Is this a case where vectorization is not possible?
For your information, gcc (Version 9.2.0) will work with vectorization if you
add -fopenmp and -O3.
ng.c:
#define SIZE 1000
float a[SIZE][SIZE],b[SIZE][SIZE],c[SIZE][SIZE];
void sub(int n) {
int i,j;
#pragma omp parallel for
for (j=0;j<n;++j) {
for (i=0;i<n;++i) {
c[j][i] = a[j][i] + b[j][i];
}
}
}
$ clang -S -O2 ng.c -Rpass=vector -Rpass-analysis=vector
ng.c:10:5: remark: vectorized loop (vectorization width: 4, interleaved count:
2) [-Rpass=loop-vectorize]
for (i=0;i<n;++i) {
^
$ clang -S -O2 ng.c -Rpass=vector -Rpass-analysis=vector -fopenmp
ng.c:10:5: remark: loop not vectorized: could not determine number of loop
iterations [-Rpass-analysis=loop-vectorize]
for (i=0;i<n;++i) {
^
$
$ gcc-9.2.0 -O2 ng.c -fopenmp -fopt-info -Wall -S $ gcc-9.2.0 -O3 ng.c -fopenmp
-fopt-info -Wall -S
ng.c:10:5: optimized: loop vectorized using 16 byte vectors
ng.c:10:5: optimized: loop with 2 iterations completely unrolled (header
execution count 64530389) $
ok.c:
#define SIZE 1000
float a[SIZE][SIZE],b[SIZE][SIZE],c[SIZE][SIZE];
void sub(int n) {
int i,j;
#pragma omp parallel for
for (j=0;j<SIZE;++j) {
for (i=0;i<SIZE;++i) {
c[j][i] = a[j][i] + b[j][i];
}
}
}
$ clang -S -O2 ok.c -Rpass=vector -Rpass-analysis=vector
ok.c:10:5: remark: vectorized loop (vectorization width: 4, interleaved count:
2) [-Rpass=loop-vectorize]
for (i=0;i<SIZE;++i) {
^
$ clang -S -O2 ok.c -Rpass=vector -Rpass-analysis=vector -fopenmp
ok.c:10:5: remark: vectorized loop (vectorization width: 4, interleaved count:
2) [-Rpass=loop-vectorize]
for (i=0;i<SIZE;++i) {
^
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs