<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 - [AVX] wrong answer after SLP Vectorizer"
href="https://bugs.llvm.org/show_bug.cgi?id=34665">34665</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[AVX] wrong answer after SLP Vectorizer
</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 gives wrong answer after SLP Vectorizer:
================= nice.c ==============
void init (unsigned int a [], unsigned int n)
{
unsigned int j = 0;
for (j = 0; j < n; j++)
a[j] = (45 + j);
}
int main ()
{
unsigned int i = 0, k = 0, j = 0, res = 0;
unsigned int z [64] = {0}, x [64] = {0};
init((unsigned int * )x, 64);
scanf(0);
for (i = 1; i < 6; ++i)
{
for (k = 9; k > 1; --k)
x[k] -= k;
for (j = 2; j < 10; ++j)
z[j] = x[j];
}
printf("res = %u\n", z[8]);
return 0;
}
============================================
<span class="quote">>>> clang -v</span >
clang version 6.0.0 (trunk 313612)
Target: x86_64-unknown-linux-gnu
Thread model: posix
...
<span class="quote">>>> clang -march=skylake -O0 -o nice.exe nice.c
>>> ./nice.exe</span >
res = 13
<span class="quote">>>> clang -march=skylake -O2 -o nice.exe nice.c
>>> ./nice.exe</span >
res = 5
If we look at generated asm, we'll see that after SLP vectorization
storage to ymm2 register is in wrong place, so it result gets an additional
subtraction:
================= nice.s ==================
...
callq scanf
vmovdqu 8(%rsp), %xmm0 # $rsp = [45, 46, 47, 48, 49, 50, 51,
52, 53, 54, ...]
vmovdqu 24(%rsp), %xmm1
vpextrd $3, %xmm1, %r8d
leal -9(%r8), %ecx
movl %ecx, 36(%rsp)
vpextrd $2, %xmm1, %r9d
leal -8(%r9), %edx
movl %edx, 32(%rsp)
vpextrd $1, %xmm1, %esi
leal -7(%rsi), %edx
movl %edx, 28(%rsp)
vpextrd $3, %xmm0, %edi
leal -5(%rdi), %edx
vmovdqu 8(%rsp), %ymm2 # $ymm2 = [47, 48, 49, 50, 51, 45, 45, 45]
...
vpaddd .LCPI1_12(%rip), %ymm2, %ymm0 # .LCPI1_12(%rip) =
[-10, -15, -20, -25, -30, -35, -40, -45]
vmovdqu %ymm0, 8(%rsp) # $rsp = [37, 33, 29, 25, 21,
10, 5, 0] - wrong answer
vmovups 8(%rsp), %ymm0 # right answer is [37, 33,
29, 25, 21, 17, 13, 9]
...
===========================================</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>