<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 - [SLPVectorizer] reorderInputsAccordingToOpcode - Match extractelement source vectors"
href="https://bugs.llvm.org/show_bug.cgi?id=41304">41304</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[SLPVectorizer] reorderInputsAccordingToOpcode - Match extractelement source vectors
</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>Windows NT
</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>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>llvm-dev@redking.me.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>a.bataev@hotmail.com, dtemirbulatov@gmail.com, llvm-bugs@lists.llvm.org, spatel+llvm@rotateright.com, v.porpodas@gmail.com
</td>
</tr></table>
<p>
<div>
<pre><a href="https://godbolt.org/z/L_m3rG">https://godbolt.org/z/L_m3rG</a>
define <4 x i32> @add_v4i32(<4 x i32> %a, <4 x i32> %b) {
%a0 = extractelement <4 x i32> %a, i32 0
%a1 = extractelement <4 x i32> %a, i32 1
%a2 = extractelement <4 x i32> %a, i32 2
%a3 = extractelement <4 x i32> %a, i32 3
%b0 = extractelement <4 x i32> %b, i32 0
%b1 = extractelement <4 x i32> %b, i32 1
%b2 = extractelement <4 x i32> %b, i32 2
%b3 = extractelement <4 x i32> %b, i32 3
%c0 = add i32 %a0, %b0
%c1 = add i32 %b1, %a1 ; commute me
%c2 = add i32 %b2, %a2 ; commute me
%c3 = add i32 %a3, %b3
%d0 = insertelement <4 x i32> undef, i32 %c0, i32 0
%d1 = insertelement <4 x i32> %d0, i32 %c1, i32 1
%d2 = insertelement <4 x i32> %d1, i32 %c2, i32 2
%d3 = insertelement <4 x i32> %d2, i32 %c3, i32 3
ret <4 x i32> %d3
}
We miss commutation chances by not checking if extractelement ops come from the
same source vector.
trunk:
define <4 x i32> @add_v4i32(<4 x i32> %a, <4 x i32> %b) {
%1 = shufflevector <4 x i32> %b, <4 x i32> %a, <4 x i32> <i32 4, i32 1, i32
2, i32 7>
%2 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 1, i32
2, i32 7>
%3 = add <4 x i32> %1, %2
ret <4 x i32> %3
}
when it could be:
define <4 x i32> @add_v4i32(<4 x i32> %a, <4 x i32> %b) {
%1 = add <4 x i32> %a, %b
ret <4 x i32> %1
}</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>