[llvm-bugs] [Bug 42384] New: miscompile with Loop Vectorizer on a simple double-nested loop
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jun 25 07:50:47 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=42384
Bug ID: 42384
Summary: miscompile with Loop Vectorizer on a simple
double-nested loop
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Loop Optimizer
Assignee: unassignedbugs at nondot.org
Reporter: fedor.v.sergeev at gmail.com
CC: llvm-bugs at lists.llvm.org
Created attachment 22137
--> https://bugs.llvm.org/attachment.cgi?id=22137&action=edit
bad-vector.ll
Consider this C testcase:
] cat vector.c
extern int printf(const char*, ...);
long mainTest() {
int byFld = 0;
long instanceCount=0;
int i24=0;
for (int i25 = 0; ++i25 < 260;) {
i24 += i25;
for (int i30 = 1; i30 < 31; i30++) {
instanceCount += (i30 ^ byFld);
byFld -= (char)i24;
}
}
return instanceCount;
}
int main() {
printf("%ld\n", mainTest());
}
] gcc -m64 vector.c; ./a.out
-139279619
]
Attached is IR produced and reduced from an equivalent Java program,
snapshotted right before Loop Vectorizer. It looks basically as what you would
expect to see by translating the above C code into IR, yet I did not bother to
find exact sequence of clang optimizations that could show me the same result.
] grep -n define bad-vector.ll
6:define i64 @mainTest() {
49:define i32 @main() {
] bin/opt bad-vector.ll | bin/lli
-139279619
As you see, the result matches the expected output shown above.
Now adding loop-vectorizer:
] bin/opt -passes=loop-vectorize bad-vector.ll | bin/lli
-139446659
and here is a wrong result.
--
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/20190625/2131ffd9/attachment.html>
More information about the llvm-bugs
mailing list