<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Wrong result after Loop Vectorization."
href="https://bugs.llvm.org/show_bug.cgi?id=35531">35531</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Wrong result after Loop Vectorization.
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ilia.taraban@intel.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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;
}
=======================================
<span class="quote">>>> clang -v</span >
clang version 6.0.0 (trunk 319765)
Target: x86_64-unknown-linux-gnu
Thread model: posix
...
<span class="quote">>>> clang -O0 -o nice.exe nice.c
>> ./nice.exe</span >
2
<span class="quote">>>> clang -O2 -o nice.exe nice.c
>>> ./nice.exe</span >
0
<span class="quote">>>> clang -O2 -o nice.exe nice.c -mllvm -opt-bisect-limit=62 && ./nice.exe</span >
...
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
<span class="quote">>>> clang -O2 -o nice.exe nice.c -mllvm -opt-bisect-limit=63 && ./nice.exe</span >
...
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
}
=======================================</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>