[llvm] [InstCombine] Move extends across identity shuffles. (PR #146901)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 6 22:32:36 PDT 2025
================
@@ -2591,15 +2590,31 @@ static Instruction *foldCastShuffle(ShuffleVectorInst &Shuf,
return nullptr;
}
+ VectorType *CastSrcTy = cast<VectorType>(Cast0->getSrcTy());
VectorType *ShufTy = Shuf.getType();
VectorType *ShufOpTy = cast<VectorType>(Shuf.getOperand(0)->getType());
- VectorType *CastSrcTy = cast<VectorType>(Cast0->getSrcTy());
// TODO: Allow length-increasing shuffles?
if (ShufTy->getElementCount().getKnownMinValue() >
ShufOpTy->getElementCount().getKnownMinValue())
return nullptr;
+ // shuffle (cast X), Poison, identity-with-extract-mask -->
+ // cast (shuffle X, Poison, identity-with-extract-mask).
+ if (Cast0->hasOneUse() && Shuf.isIdentityWithExtract() &&
+ isa<PoisonValue>(Shuf.getOperand(1))) {
----------------
arsenm wrote:
```suggestion
if (isa<PoisonValue>(Shuf.getOperand(1) &&
Cast0->hasOneUse() && Shuf.isIdentityWithExtract())) {
```
Do you really need to check for poison? I would assume that's covered under the Shuf check?
https://github.com/llvm/llvm-project/pull/146901
More information about the llvm-commits
mailing list