https://bugs.llvm.org/show_bug.cgi?id=32486
Bug ID: 32486
Summary: Instcombine: shufflevector with undef mask
overaggressively simplified to an undef constant?
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: Scalar Optimizations
Assignee: unassignedb...@nondot.org
Reporter: zvi.racko...@intel.com
CC: llvm-bugs@lists.llvm.org
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 https://reviews.llvm.org/D31525#715234:
"
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."
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs