<html>
<head>
<base href="https://llvm.org/bugs/" />
</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 --- - short fixed count loops are not vectorized without #pragma hints"
href="https://llvm.org/bugs/show_bug.cgi?id=28434">28434</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>short fixed count loops are not vectorized without #pragma hints
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.8
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nowak-llvm@tepeserwery.pl
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>see <a href="https://godbolt.org/g/bLIzA1">https://godbolt.org/g/bLIzA1</a>
void f1(float *__restrict__ q __attribute__((align_value(16))), int
*__restrict__ p __attribute__((align_value(16)))) {
#pragma clang loop unroll(disable)
#pragma clang loop vectorize(enable)
for (unsigned int i = 0; i < 4; ++i) {
q[i] = p[i];
}
}
void f2(float *__restrict__ q __attribute__((align_value(16))), int
*__restrict__ p __attribute__((align_value(16)))) {
#pragma clang loop vectorize(enable)
for (unsigned int i = 0; i < 4; ++i) {
q[i] = p[i];
}
}
void f3(float *__restrict__ q __attribute__((align_value(16))), int
*__restrict__ p __attribute__((align_value(16)))) {
#pragma clang loop unroll(disable)
for (unsigned int i = 0; i < 4; ++i) {
q[i] = p[i];
}
}
void f4(float *__restrict__ q __attribute__((align_value(16))), int
*__restrict__ p __attribute__((align_value(16)))) {
for (unsigned int i = 0; i < 4; ++i) {
q[i] = p[i];
}
}
void f5(float *__restrict__ q __attribute__((align_value(16))), int
*__restrict__ p __attribute__((align_value(16)))) {
for (unsigned int i = 0; i < 40; ++i) {
q[i] = p[i];
}
}
f1 is correctly vectorized when vectorization is forced and loop unrolling
disabled:
cvtdq2ps (%rsi), %xmm0
movaps %xmm0, (%rdi)
f2 is not correctly vectorized even when vectorization is forced because loop
is fully unrolled before vectorization?:
cvtsi2ssl (%rsi), %xmm0
movss %xmm0, (%rdi)
xorps %xmm0, %xmm0
cvtsi2ssl 4(%rsi), %xmm0
movss %xmm0, 4(%rdi)
xorps %xmm0, %xmm0
...
f3 is not correctly vectorized when loop unrolling is disabled but
vectorization is not forced:
xorl %eax, %eax
.LBB2_1: # =>This Inner Loop Header: Depth=1
xorps %xmm0, %xmm0
cvtsi2ssl (%rsi,%rax,4), %xmm0
movss %xmm0, (%rdi,%rax,4)
incq %rax
cmpq $4, %rax
jne .LBB2_1
f4 without any #pragma is not correctly vectorized but is unrolled and produces
same code as f2.
f5 without any #pragma is correctly vectorized and unrolled only when loop
count is ~40 or higher:
cvtdq2ps (%rsi), %xmm0
movaps %xmm0, (%rdi)
cvtdq2ps 16(%rsi), %xmm0
movaps %xmm0, 16(%rdi)
...</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>