<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 - SLP vectorizer: aligned store to unaligned address"
href="https://bugs.llvm.org/show_bug.cgi?id=34219">34219</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>SLP vectorizer: aligned store to unaligned address
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</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>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>vsna7ma4he@jorrit.de
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>The reproducer causes clang++ to generate a movdqa instruction to an address
that is not sufficiently aligned, causing a SEGFAULT on x86-64. This happens
with -O2, but not with -O2 -fno-slp-vectorize. This was originally observed
with
clang version 3.8.0 (tags/RELEASE_380/final 263969)
<a href="http://coliru.stacked-crooked.com/a/159167c4e00de3bd">http://coliru.stacked-crooked.com/a/159167c4e00de3bd</a>
it can still be seen in the assembler output of what godbolt calls clang trunk
clang version 6.0.0 (trunk 310993)
<a href="https://godbolt.org/g/oF9WT1">https://godbolt.org/g/oF9WT1</a>
The offending instruction is this store -- movdqa requires alignment to 16
bytes, but the address is only aligned to 8 bytes.
movdqa %xmm0,0x200b3d(%rip) # 601058 <counters+0x8>
reproducer.cc:
====================
// compile with:
// clang++ -std=c++14 -O2 -Wall -g -pedantic -pthread reproducer.cpp
long m = 3;
struct alignas(16) Counters {
long padding;
long c0;
long c1;
} counters;
int main() {
++counters.c0; ++counters.c1;
if(m & 1) { ++counters.c0; ++counters.c1; }
if(m & 2) { ++counters.c0; ++counters.c1; }
}
====================
Disassmbly (clang trunk from godbolt). The offending instruction is the
fourth from the bottom.
====================
.plt.got:
jmpq *0x200c12(%rip) # 600ff8 <_DYNAMIC+0x200>
xchg %ax,%ax
main:
movdqu 0x200b80(%rip),%xmm1 # 601058 <counters+0x8>
pcmpeqd %xmm2,%xmm2
movdqa %xmm1,%xmm0
psubq %xmm2,%xmm0
movdqu %xmm0,0x200b6c(%rip) # 601058 <counters+0x8>
mov 0x200b3d(%rip),%rax # 601030 <m>
test $0x1,%al
je 400503 <main+0x33>
paddq 0xb1(%rip),%xmm1 # 4005b0 <_IO_stdin_used+0x10>
movdqa %xmm1,%xmm0
test $0x3,%al
je 40051b <main+0x4b>
test $0x2,%al
je 400513 <main+0x43>
pcmpeqd %xmm1,%xmm1
psubq %xmm1,%xmm0
movdqa %xmm0,0x200b3d(%rip) # 601058 <counters+0x8>
xor %eax,%eax
retq
xchg %ax,%ax
====================</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>