[llvm-bugs] [Bug 41572] New: Miscompile of collapse(2) with non-rectangular loop nest
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Apr 23 10:41:20 PDT 2019
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: unassignedclangbugs at nondot.org
Reporter: llvm at meinersbur.de
CC: a.bataev at hotmail.com, hfinkel at anl.gov,
jdoerfert at anl.gov, llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190423/daa595d5/attachment.html>
More information about the llvm-bugs
mailing list