<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 --- - SLP Vectorizer does not correctly widen loads when vectorizing reductions"
href="https://llvm.org/bugs/show_bug.cgi?id=28474">28474</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>SLP Vectorizer does not correctly widen loads when vectorizing reductions
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Loop Optimizer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mkuper@google.com
</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>Consider:
void foo();
int test1(unsigned int *p) {
int sum = 0;
#pragma nounroll
for (int y = 0; y < 2; y++) {
// Inner loop gets unrolled
for (int x = 0; x < 8; x++) {
sum += p[x] * 42;
}
// Dummy call to keep outer loop alive
foo();
}
return sum;
}
The body of the outer loop gets vectorized (see PR25748 for why the loop is so
odd-looking), but the loads and not properly widened, and we get:
%0 = load i32, i32* %p, align 4, !tbaa !1
%1 = load i32, i32* %arrayidx.1, align 4, !tbaa !1
%2 = load i32, i32* %arrayidx.2, align 4, !tbaa !1
%3 = load i32, i32* %arrayidx.3, align 4, !tbaa !1
%4 = load i32, i32* %arrayidx.4, align 4, !tbaa !1
%5 = load i32, i32* %arrayidx.5, align 4, !tbaa !1
%6 = load i32, i32* %arrayidx.6, align 4, !tbaa !1
%7 = load i32, i32* %arrayidx.7, align 4, !tbaa !1
%8 = insertelement <8 x i32> undef, i32 %7, i32 0
%9 = insertelement <8 x i32> %8, i32 %6, i32 1
%10 = insertelement <8 x i32> %9, i32 %5, i32 2
%11 = insertelement <8 x i32> %10, i32 %4, i32 3
%12 = insertelement <8 x i32> %11, i32 %3, i32 4
%13 = insertelement <8 x i32> %12, i32 %2, i32 5
%14 = insertelement <8 x i32> %13, i32 %1, i32 6
%15 = insertelement <8 x i32> %14, i32 %0, i32 7
This problem is specific to reductions, when building the tree from a store,
everything is fine. I think what's happening is that when vectorizing
reductions, the loads are collected in reverse order, so we don't notice they
are consecutive. But I still need to verify this.</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>