@@ -708,17 +708,15 @@ static Instruction *shrinkSplatShuffle(TruncInst &Trunc,
708
708
auto *Shuf = dyn_cast<ShuffleVectorInst>(Trunc.getOperand (0 ));
709
709
if (Shuf && Shuf->hasOneUse () && match (Shuf->getOperand (1 ), m_Undef ()) &&
710
710
all_equal (Shuf->getShuffleMask ()) &&
711
- Shuf->getType ()->getScalarType () ==
712
- Shuf->getOperand (0 )->getType ()->getScalarType ()) {
711
+ ElementCount::isKnownGE (Shuf->getType ()->getElementCount (),
712
+ cast<VectorType>(Shuf->getOperand (0 )->getType ())
713
+ ->getElementCount ())) {
713
714
// trunc (shuf X, Undef, SplatMask) --> shuf (trunc X), Poison, SplatMask
714
715
// trunc (shuf X, Poison, SplatMask) --> shuf (trunc X), Poison, SplatMask
715
- auto *const NewTruncTy = VectorType::get (
716
- Trunc.getType ()->getScalarType (),
717
- cast<VectorType>(Shuf->getOperand (0 )->getType ())->getElementCount ());
718
- Value *NarrowOp =
719
- Builder.CreateTrunc (Shuf->getOperand (0 ), NewTruncTy, Trunc.getName ());
720
- return new ShuffleVectorInst (NarrowOp, Shuf->getShuffleMask (),
721
- Shuf->getName ());
716
+ Type *const NewTruncTy = Shuf->getOperand (0 )->getType ()->getWithNewType (
717
+ Trunc.getType ()->getScalarType ());
718
+ Value *NarrowOp = Builder.CreateTrunc (Shuf->getOperand (0 ), NewTruncTy);
719
+ return new ShuffleVectorInst (NarrowOp, Shuf->getShuffleMask ());
722
720
}
723
721
724
722
return nullptr ;
0 commit comments