[llvm] 263224e - [InstCombine] Require poison operand in canEvaluateShuffled transform
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue May 21 06:00:15 PDT 2024
Author: Nikita Popov
Date: 2024-05-21T15:00:01+02:00
New Revision: 263224e4481b0850539a93a272184aac4abe86d4
URL: https://github.com/llvm/llvm-project/commit/263224e4481b0850539a93a272184aac4abe86d4
DIFF: https://github.com/llvm/llvm-project/commit/263224e4481b0850539a93a272184aac4abe86d4.diff
LOG: [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.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
llvm/test/Transforms/InstCombine/vec_shuffle.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index 99f1f8eb34bb5..745ccbfe9dc74 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 839279d7420ba..d36ada7756af3 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
More information about the llvm-commits
mailing list