<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 - Instcombine: shufflevector with undef mask overaggressively simplified to an undef constant?"
href="https://bugs.llvm.org/show_bug.cgi?id=32486">32486</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Instcombine: shufflevector with undef mask overaggressively simplified to an undef constant?
</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>normal
</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>zvi.rackover@intel.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>As of r299303, opt -instcombine will simplify the following function:
define <4 x float> @foo(<4 x float> %a, <4 x float> %b) {
%s = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> undef
ret <4 x float> %s
}
to:
define <4 x float> @foo(<4 x float> %a, <4 x float> %b) {
ret <4 x float> undef
}
As Sanjay pointed out in <a href="https://reviews.llvm.org/D31525#715234">https://reviews.llvm.org/D31525#715234</a>:
"
Why would a shuffle with undef mask automatically return undef? For example:
shufflevector <2 x i8> <i8 42, i8 42>, <2 x i8> <i8 42, i8 42>, <2 x i32> undef
Should this be constant folded to <i8 42, i8 42> , <2 x i8> undef or something
else?
"
This kind of simplification is implemented in these locations and possibly
others:
- Explicitly in InstCombiner::visitShuffleVectorInst
- Explicitly in ConstantFoldShuffleVectorInstruction
- InstCombiner::SimplifyDemandedVectorElts will eventually return an undef
constant
The language reference says 'The element selector may be undef (meaning “don’t
care”)...'.
"don't care" can be one of:
1. Don't care what element is selected from the input vectors
2. The respective element in the result vector is undef
We may use the examples from the 'Undefined Values' section in the language
reference to reason about shuffles in the same manner do for select's:
"This set of examples shows that undefined ‘select‘ (and conditional branch)
conditions can go either way, but they have to come from one of the two
operands."</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>