From fbc798e4426b322ed0e03019c20d929f2eaade22 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 21 May 2024 15:47:46 +0200 Subject: [PATCH] [InstCombine] Use m_Poison instead of m_Undef (NFCI) In this case, isIdentityWithExtract() should already ensure that this is a single-source shuffle. This just makes things more explicit. --- llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp index ef30f28c3da7fe..9dcd9ef07d74f1 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp @@ -2549,7 +2549,7 @@ static Instruction *foldCastShuffle(ShuffleVectorInst &Shuf, /// Try to fold an extract subvector operation. static Instruction *foldIdentityExtractShuffle(ShuffleVectorInst &Shuf) { Value *Op0 = Shuf.getOperand(0), *Op1 = Shuf.getOperand(1); - if (!Shuf.isIdentityWithExtract() || !match(Op1, m_Undef())) + if (!Shuf.isIdentityWithExtract() || !match(Op1, m_Poison())) return nullptr; // Check if we are extracting all bits of an inserted scalar: @@ -2578,10 +2578,10 @@ static Instruction *foldIdentityExtractShuffle(ShuffleVectorInst &Shuf) { // not allow arbitrary shuffle mask creation as a target-independent transform // (because we can't guarantee that will lower efficiently). // - // If the extracting shuffle has an undef mask element, it transfers to the + // If the extracting shuffle has an poison mask element, it transfers to the // new shuffle mask. Otherwise, copy the original mask element. Example: - // shuf (shuf X, Y, ), undef, <0, undef, 2, 3> --> - // shuf X, Y, + // shuf (shuf X, Y, ), poison, <0, poison, 2, 3> --> + // shuf X, Y, unsigned NumElts = cast(Shuf.getType())->getNumElements(); SmallVector NewMask(NumElts); assert(NumElts < Mask.size() &&