<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 --- - [loop vectorize] Simple loop calculation on signed chars does not vectorize"
href="https://llvm.org/bugs/show_bug.cgi?id=22896">22896</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[loop vectorize] Simple loop calculation on signed chars does not vectorize
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Other
</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>wschmidt@linux.vnet.ibm.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>A very simple test case is not vectorized, at least for powerpc64le.
void abort();
#define N 16
signed char ca[N] __attribute__((aligned(16)));
signed char cb[] __attribute__((aligned(16)))
= {8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7};
signed char cc[] __attribute__((aligned(16)))
= {1, 1, 2, 2, 3, 3, 2, 2, 1, 1, 0, 0, -1, -1, -2, -2};
__attribute__((noinline)) void foo ()
{
int i;
for (i = 0; i < N; i++) {
ca[i] = cb[i] - cc[i];
}
}
int main ()
{
signed char cd[] = {7, 6, 4, 3, 1, 0, 0, -1, -1, -2, -2, -3, -3, -4, -4, -5};
int i;
foo ();
for (i = 0; i < N; ++i)
if (ca[i] != cd[i])
abort ();
return 0;
}
Compiling with -O3 -target powerpc64le-unknown-linux-gnu -S produces this as
the core loop in foo():
.LBB0_1: # %for.body
# =>This Inner Loop Header: Depth=1
lbzu 6, 4(5)
lbzu 7, 4(4)
lbz 8, 1(5)
lbz 10, 2(5)
lbz 12, 3(5)
lbz 9, 1(4)
lbz 11, 2(4)
lbz 0, 3(4)
subf 6, 7, 6
stbu 6, 4(3)
subf 9, 9, 8
subf 11, 11, 10
subf 12, 0, 12
stb 9, 1(3)
stb 11, 2(3)
stb 12, 3(3)
bdnz .LBB0_1
GCC, though, fully unrolls the loop and generates vectorized code (address
setup code omitted):
lxvd2x 32,0,9
lxvd2x 33,9,10
vsububm 0,0,1
stxvd2x 32,0,9
Methinks we should do that, too. ;)
CCing Hal and Kit. Hal, Kit is interested in looking at this as a learning
activity, so no need to jump on this unless you feel it can't wait.</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>