[llvm-bugs] [Bug 36589] New: [LoopVersioningLICM] wrong code
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Mar 3 04:32:00 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=36589
Bug ID: 36589
Summary: [LoopVersioningLICM] wrong code
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: paulsson at linux.vnet.ibm.com
CC: llvm-bugs at lists.llvm.org
Created attachment 19994
--> https://bugs.llvm.org/attachment.cgi?id=19994&action=edit
reduced test case
It seems that passing -loop-versioning-licm produces wrong result with the
following reduced csmith program:
a[6];
int b = 5, c = 0, d = 0, f = 0, j = 0;
short e = 0, i = 0;
g[50];
*h = &f;
main() {
for (; c < 6; c++)
a[5] = c;
for (; e >= 0; e--) {
*h = 1;
d = 0;
for (; d <= 4; d++) {
g[e] = i;
g[d] = 80;
}
}
b = a[b ^ g[j]];
printf("checksum = %X\n", b);
}
The checksum becomes 0 instead of 5 (per 8 other compilations).
I added some extra printf statements like:
...
for (; d <= 4; d++) {
g[e] = i;
g[d] = 80;
}
}
printf("b = %d, g[0]=%d, ", b, g[0]);
int L = b ^ g[j];
printf ("L = %d ", L);
b = a[L];
printf("b = %d, j = %d ", b, j);
printf("checksum = %X\n", b);
}
and got
...
b = 5, g[0]=0, L = 5 b = 5, j = 0 checksum = 5
...
b = 5, g[0]=80, L = 85 b = 0, j = 0 checksum = 0
, which shows that g[0] is 80, and not 0 as it should be, since i and e are
constant 0.
A minimal opt line, and debug output:
bin/opt -mtriple=s390x-linux-gnu -mcpu=z13 tc_lv_licm.bc -o tc_lv_licm.opt.ll
-S -tbaa -scoped-noalias -loop-rotate -licm -loop-unroll -gvn -sccp -instcombin
e -globalopt -loop-versioning-licm -licm -debug-only=loop-versioning-licm
Loop: Loop at depth 1 containing:
%for.body4<header>,%for.body8.lr.ph,%for.body8.prol.preheader,%for.body8.prol,%for.body8.prol.loopexit.unr-lcssa,%for.body8.prol.loopexit,%for.body8.lr.ph.ne
w,%for.body8,%for.cond5.for.end14_crit_edge.unr-lcssa,%for.cond5.for.end14_crit_edge,%for.end14<latch><exiting>
Loop Versioning found to be beneficial
Loop: Loop at depth 1 containing: %for.body<header><latch><exiting>
LAA: Runtime check not found !!
Loop instructions not suitable for LoopVersioningLICM
Loop: Loop at depth 1 containing: %for.body.prol<header><latch><exiting>
Parallel loop is not worth versioning
Loop structure not suitable for LoopVersioningLICM
It seems then that it is only one loop that is handled.
--
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/20180303/dd9ea2f1/attachment-0001.html>
More information about the llvm-bugs
mailing list