Skip to content

Commit 263224e

Browse files
committed
[InstCombine] Require poison operand in canEvaluateShuffled transform
This transform works on single-source shuffles, which require that the second operand is poison, not undef. Otherwise we may convert undef to poison. Fixes #92887.
1 parent f78b1a4 commit 263224e

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2901,7 +2901,7 @@ Instruction *InstCombinerImpl::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
29012901
if (Instruction *I = foldIdentityPaddedShuffles(SVI))
29022902
return I;
29032903

2904-
if (match(RHS, m_Undef()) && canEvaluateShuffled(LHS, Mask)) {
2904+
if (match(RHS, m_Poison()) && canEvaluateShuffled(LHS, Mask)) {
29052905
Value *V = evaluateInDifferentElementOrder(LHS, Mask, Builder);
29062906
return replaceInstUsesWith(SVI, V);
29072907
}

llvm/test/Transforms/InstCombine/vec_shuffle.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,10 +2331,9 @@ define <4 x i16> @blend_elements_from_load(ptr align 8 %_0) {
23312331
ret <4 x i16> %rv
23322332
}
23332333

2334-
; FIXME: This is a miscompile.
23352334
define i16 @pr92887(<2 x i16> %v) {
23362335
; CHECK-LABEL: @pr92887(
2337-
; CHECK-NEXT: ret i16 poison
2336+
; CHECK-NEXT: ret i16 undef
23382337
;
23392338
%v0 = extractelement <2 x i16> %v, i64 0
23402339
%v0lo = and i16 %v0, 1

0 commit comments

Comments
 (0)