Skip to content

Commit 8d5b7d4

Browse files
committed
[InstCombine] Use m_Poison() instead of m_Undef() (NFCI)
In this case, the isIdentityWithExtract() checks should already guarantee that these are single-source shuffles, so this is just for clarity.
1 parent d0e0205 commit 8d5b7d4

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,13 +2416,13 @@ static Instruction *foldTruncShuffle(ShuffleVectorInst &Shuf,
24162416
}
24172417

24182418
/// Match a shuffle-select-shuffle pattern where the shuffles are widening and
2419-
/// narrowing (concatenating with undef and extracting back to the original
2419+
/// narrowing (concatenating with poison and extracting back to the original
24202420
/// length). This allows replacing the wide select with a narrow select.
24212421
static Instruction *narrowVectorSelect(ShuffleVectorInst &Shuf,
24222422
InstCombiner::BuilderTy &Builder) {
24232423
// This must be a narrowing identity shuffle. It extracts the 1st N elements
24242424
// of the 1st vector operand of a shuffle.
2425-
if (!match(Shuf.getOperand(1), m_Undef()) || !Shuf.isIdentityWithExtract())
2425+
if (!match(Shuf.getOperand(1), m_Poison()) || !Shuf.isIdentityWithExtract())
24262426
return nullptr;
24272427

24282428
// The vector being shuffled must be a vector select that we can eliminate.
@@ -2432,19 +2432,20 @@ static Instruction *narrowVectorSelect(ShuffleVectorInst &Shuf,
24322432
m_OneUse(m_Select(m_Value(Cond), m_Value(X), m_Value(Y)))))
24332433
return nullptr;
24342434

2435-
// We need a narrow condition value. It must be extended with undef elements
2435+
// We need a narrow condition value. It must be extended with poison elements
24362436
// and have the same number of elements as this shuffle.
24372437
unsigned NarrowNumElts =
24382438
cast<FixedVectorType>(Shuf.getType())->getNumElements();
24392439
Value *NarrowCond;
2440-
if (!match(Cond, m_OneUse(m_Shuffle(m_Value(NarrowCond), m_Undef()))) ||
2440+
if (!match(Cond, m_OneUse(m_Shuffle(m_Value(NarrowCond), m_Poison()))) ||
24412441
cast<FixedVectorType>(NarrowCond->getType())->getNumElements() !=
24422442
NarrowNumElts ||
24432443
!cast<ShuffleVectorInst>(Cond)->isIdentityWithPadding())
24442444
return nullptr;
24452445

2446-
// shuf (sel (shuf NarrowCond, undef, WideMask), X, Y), undef, NarrowMask) -->
2447-
// sel NarrowCond, (shuf X, undef, NarrowMask), (shuf Y, undef, NarrowMask)
2446+
// shuf (sel (shuf NarrowCond, poison, WideMask), X, Y), poison, NarrowMask)
2447+
// -->
2448+
// sel NarrowCond, (shuf X, poison, NarrowMask), (shuf Y, poison, NarrowMask)
24482449
Value *NarrowX = Builder.CreateShuffleVector(X, Shuf.getShuffleMask());
24492450
Value *NarrowY = Builder.CreateShuffleVector(Y, Shuf.getShuffleMask());
24502451
return SelectInst::Create(NarrowCond, NarrowX, NarrowY);

0 commit comments

Comments
 (0)