<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 - [LoopVectorizer] Vectorization of running reduction/predication"
href="https://bugs.llvm.org/show_bug.cgi?id=50942">50942</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[LoopVectorizer] Vectorization of running reduction/predication
</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>enhancement
</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>lebedev.ri@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Consider <a href="https://godbolt.org/z/Wo86sfav1">https://godbolt.org/z/Wo86sfav1</a>
void test(int pred, int* data, int width) {
for(int i = 0; i != width; ++i) {
int& out = data[i];
pred += out;
out = pred;
}
}
So the first element was incremented by `pred`,
and each next element is incremented by the value of all preceding elements.
This is a common pattern in image processing.
Currently we don't recognize the PHI, and don't vectorize,
even though it's somewhat simple:
<a href="https://godbolt.org/z/sEob7fE6h">https://godbolt.org/z/sEob7fE6h</a>
That snippet as-is doesn't seem better vectorized:
<a href="https://godbolt.org/z/aMaqYz7f1">https://godbolt.org/z/aMaqYz7f1</a>
(better RThroughput, same cycle count, but more uOps/IPC)
However if we unroll x8 <a href="https://godbolt.org/z/Mb7vcGrzs">https://godbolt.org/z/Mb7vcGrzs</a>
(and i do believe both loops unrolled still compute the same elt count)
i think we see a win: <a href="https://godbolt.org/z/EW77Max86">https://godbolt.org/z/EW77Max86</a>
A ~third less cycles.
This makes sense because most of the computations there don't touch `pred`,
so they can be executed out-of-order, even though we won't be able to
finish and store until the previous group has finished processing.
The story will be somewhat different with two-element predictor,
different data types, etc.
Is this recipe something that could fit into LV?</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>