aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2024-05-21 14:57:19 +0200
committerNikita Popov <npopov@redhat.com>2024-05-21 15:00:01 +0200
commit263224e4481b0850539a93a272184aac4abe86d4 (patch)
treea281ac7b21e1a24f6a3bf32b5c52b3dfcc3c727b
parentf78b1a40864470f7eb30dfda44a6ea8e845346a5 (diff)
downloadllvm-263224e4481b0850539a93a272184aac4abe86d4.zip
llvm-263224e4481b0850539a93a272184aac4abe86d4.tar.gz
llvm-263224e4481b0850539a93a272184aac4abe86d4.tar.bz2
[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 https://github.com/llvm/llvm-project/issues/92887.
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp2
-rw-r--r--llvm/test/Transforms/InstCombine/vec_shuffle.ll3
2 files changed, 2 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index 99f1f8e..745ccbf 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -2901,7 +2901,7 @@ Instruction *InstCombinerImpl::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
if (Instruction *I = foldIdentityPaddedShuffles(SVI))
return I;
- if (match(RHS, m_Undef()) && canEvaluateShuffled(LHS, Mask)) {
+ if (match(RHS, m_Poison()) && canEvaluateShuffled(LHS, Mask)) {
Value *V = evaluateInDifferentElementOrder(LHS, Mask, Builder);
return replaceInstUsesWith(SVI, V);
}
diff --git a/llvm/test/Transforms/InstCombine/vec_shuffle.ll b/llvm/test/Transforms/InstCombine/vec_shuffle.ll
index 839279d..d36ada7 100644
--- a/llvm/test/Transforms/InstCombine/vec_shuffle.ll
+++ b/llvm/test/Transforms/InstCombine/vec_shuffle.ll
@@ -2331,10 +2331,9 @@ define <4 x i16> @blend_elements_from_load(ptr align 8 %_0) {
ret <4 x i16> %rv
}
-; FIXME: This is a miscompile.
define i16 @pr92887(<2 x i16> %v) {
; CHECK-LABEL: @pr92887(
-; CHECK-NEXT: ret i16 poison
+; CHECK-NEXT: ret i16 undef
;
%v0 = extractelement <2 x i16> %v, i64 0
%v0lo = and i16 %v0, 1