[llvm] [InstCombine] Let shrinkSplatShuffle act on vectors of different lengths (PR #148593)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 15 22:07:23 PDT 2025
================
@@ -708,11 +708,17 @@ static Instruction *shrinkSplatShuffle(TruncInst &Trunc,
auto *Shuf = dyn_cast<ShuffleVectorInst>(Trunc.getOperand(0));
if (Shuf && Shuf->hasOneUse() && match(Shuf->getOperand(1), m_Undef()) &&
all_equal(Shuf->getShuffleMask()) &&
- Shuf->getType() == Shuf->getOperand(0)->getType()) {
+ ElementCount::isKnownGE(Shuf->getType()->getElementCount(),
+ cast<VectorType>(Shuf->getOperand(0)->getType())
+ ->getElementCount())) {
// trunc (shuf X, Undef, SplatMask) --> shuf (trunc X), Poison, SplatMask
// trunc (shuf X, Poison, SplatMask) --> shuf (trunc X), Poison, SplatMask
- Value *NarrowOp = Builder.CreateTrunc(Shuf->getOperand(0), Trunc.getType());
- return new ShuffleVectorInst(NarrowOp, Shuf->getShuffleMask());
+ auto *const NewTruncTy = Shuf->getOperand(0)->getType()->getWithNewType(
----------------
lukel97 wrote:
Style nit, avoid using auto when it doesn't make the type clearer https://llvm.org/docs/CodingStandards.html#id29
```suggestion
Type *NewTruncTy = Shuf->getOperand(0)->getType()->getWithNewType(
```
https://github.com/llvm/llvm-project/pull/148593
More information about the llvm-commits
mailing list