https://bugs.llvm.org/show_bug.cgi?id=41572
Bug ID: 41572
Summary: Miscompile of collapse(2) with non-rectangular loop
nest
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: OpenMP
Assignee: unassignedclangb...@nondot.org
Reporter: l...@meinersbur.de
CC: a.bat...@hotmail.com, hfin...@anl.gov,
jdoerf...@anl.gov, llvm-bugs@lists.llvm.org
The following program miscompiles on current trunk (r358973):
$ cat collapse.c
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
int n = 2;
bool executed = false;
#pragma omp parallel for collapse(2)
for (int i = 0; i < n; i += 1)
for (int j = i; j < n; j += 1)
executed = true;
printf("executed? %d\n", executed);
return EXIT_SUCCESS;
}
$ ~/build/llvm/release/bin/clang collapse.c -fopenmp -O3 -o collapse &&
./collapse
executed? 0
Emitting the output reveals that outlined function has been optimized away:
$ ~/build/llvm/release/bin/clang collapse.c -fopenmp -O3 -emit-llvm -S -o -
[...]
define internal void @.omp_outlined.(i32* noalias nocapture %.global_tid., i32*
noalias nocapture %.bound_tid., i32* nocapture dereferenceable(4) %n, i8*
nocapture dereferenceable(1) %executed) #2 {
entry:
ret void
}
[...]
The following do return the correct result:
$ ~/build/llvm/release/bin/clang collapse.c -o collapse -O3 && ./collapse
executed? 1
$ ~/build/llvm/release/bin/clang collapse.c -fopenmp -o collapse -O0 &&
./collapse
executed? 1
[...]
#pragma omp parallel for collapse(2)
for (int i = 0; i < n; i += 1)
for (int j = 0; j < n; j += 1) // <= rectangular loop nest
[...]
$ ~/build/llvm/release/bin/clang collapse-rect.c -fopenmp -o collapse-rect -O3
&& ./collapse-rect
executed? 1
--
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