-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Description
| Bugzilla Link | 36589 |
| Version | trunk |
| OS | Linux |
| Attachments | reduced test case |
| CC | @hfinkel,@JonPsson,@uweigand |
Extended Description
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
,%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.new,%for.body8,%for.cond5.for.end14_crit_edge.unr-lcssa,%for.cond5.for.end14_crit_edge,%for.end14
Loop Versioning found to be beneficial
Loop: Loop at depth 1 containing: %for.body
LAA: Runtime check not found !!
Loop instructions not suitable for LoopVersioningLICM
Loop: Loop at depth 1 containing: %for.body.prol
Parallel loop is not worth versioning
Loop structure not suitable for LoopVersioningLICM
It seems then that it is only one loop that is handled.