<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 - [SKX] Bus error after Loop Vectorization"
href="https://bugs.llvm.org/show_bug.cgi?id=34682">34682</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[SKX] Bus error 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>Windows NT
</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 at run with "Bus error (core dumped)" after Loop Vectorization
on O2, skx:
================= nice.c ==============
int main ()
{
unsigned int j = 0, k = 0, i = 0;
unsigned int x [17] [17] = {0}, a [17] = {0};
for (j = 1; j < 10; ++j)
for (k = j; k < 17; ++k)
for (i = 1; i < j; ++i)
x[k][0] = a[i - 1];
printf("res = %u\n", x[0][0]);
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-avx512 -O0 -o nice.exe nice.c
>>> sde -skx -- ./nice.exe</span >
res = 0
<span class="quote">>>> clang -march=skylake-avx512 -O2 -o nice.exe nice.c
>>> sde -skx -- ./nice.exe</span >
Bus error (core dumped)
<span class="quote">>>> clang -march=skylake-avx512 -O2 -o nice.exe nice.c -mllvm -opt-bisect-limit=83</span >
...
BISECT: running pass (82) Rotate Loops on loop
BISECT: running pass (83) Loop Distribution on function (main)
BISECT: NOT running pass (84) Loop Vectorization on function (main)
BISECT: NOT running pass (85) Loop Load Elimination on function (main)
...
<span class="quote">>>> sde -skx -- ./nice.exe</span >
res = 0
<span class="quote">>>> clang -march=skylake-avx512 -O2 -o nice.exe nice.c -mllvm -opt-bisect-limit=84</span >
...
BISECT: running pass (83) Loop Distribution on function (main)
BISECT: running pass (84) Loop Vectorization on function (main)
BISECT: NOT running pass (85) Loop Load Elimination on function (main)
BISECT: NOT running pass (86) Combine redundant instructions on function (main)
...
<span class="quote">>>> sde -skx -- ./nice.exe</span >
Segmentation fault (core dumped)
If we look at generated asm, we'll see that we put -1 into esi, but then use
rsi for pointer operations:
================= nice.s ==================
...
movl $16, %r10d
subq %r11, %r10
leal -1(%r11), %esi # put -1 into $esi
movq %rax, %rbx
cmpq $16, %r10
...
vpaddq %zmm12, %zmm3, %zmm12
vpbroadcastd (%rsp,%rsi,4), %ymm13 # SIGBUS rsi =
0x00000000FFFFFFFF
kmovq %k1, %k2
vpscatterqd %ymm13, (,%zmm12) {%k2}
...
===========================================
So if we change "leal -1(%r11), %esi" to "leaq -1(%r11), %rsi" , our
program will finish correctly with "res = 0"
<span class="quote">>>> clang nice-fixed.s -o nice-fixed.exe
>>> sde -skx -- ./nice-fixed.exe</span >
res = 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>