[llvm-bugs] [Bug 35531] New: Wrong result after Loop Vectorization.
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Dec 5 08:20:20 PST 2017
https://bugs.llvm.org/show_bug.cgi?id=35531
Bug ID: 35531
Summary: Wrong result after Loop Vectorization.
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: ilia.taraban at intel.com
CC: llvm-bugs at lists.llvm.org
This test fails with wrong result after Loop Vectorization:
================= nice.c ==============
unsigned int i = 0;
int main ()
{
unsigned int m = i;
unsigned int k = 1;
for (i = 0; i <= 63; ++i)
{
m &= k;
m++;
}
printf("%u\n", m);
return 0;
}
=======================================
>>> clang -v
clang version 6.0.0 (trunk 319765)
Target: x86_64-unknown-linux-gnu
Thread model: posix
...
>>> clang -O0 -o nice.exe nice.c
>> ./nice.exe
2
>>> clang -O2 -o nice.exe nice.c
>>> ./nice.exe
0
>>> clang -O2 -o nice.exe nice.c -mllvm -opt-bisect-limit=62 && ./nice.exe
...
BISECT: running pass (61) Rotate Loops on loop
BISECT: running pass (62) Loop Distribution on function (main)
BISECT: NOT running pass (63) Loop Vectorization on function (main)
BISECT: NOT running pass (64) Loop Load Elimination on function (main)
...
2
>>> clang -O2 -o nice.exe nice.c -mllvm -opt-bisect-limit=63 && ./nice.exe
...
BISECT: running pass (62) Loop Distribution on function (main)
BISECT: running pass (63) Loop Vectorization on function (main)
BISECT: NOT running pass (64) Loop Load Elimination on function (main)
BISECT: NOT running pass (65) Combine redundant instructions on function (main)
...
0
Let's look at IR before after Loop Vectorization:
============ nice.after.ll ============
...
%9 = extractelement <16 x i1> %bin.rdx6, i32 0
%10 = zext i1 %9 to i32; used i1, but variable m at the end of for can be
only 1 or 2.
%cmp.n = icmp eq i32 64, 64
br i1 %cmp.n, label %for.end, label %scalar.ph
...
for.end: ; preds = %middle.block,
%for.body
%inc.lcssa = phi i32 [ %inc, %for.body ], [ %10, %middle.block ]; result is
in %10
store i32 64, i32* @i, align 4, !tbaa !2
%call = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x
i8], [4 x i8]* @.str, i64 0, i64 0), i32 %inc.lcssa)
ret i32 0
}
=======================================
--
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/20171205/c7027ae8/attachment.html>
More information about the llvm-bugs
mailing list