@@ -708,17 +708,15 @@ static Instruction *shrinkSplatShuffle(TruncInst &Trunc,
708708 auto *Shuf = dyn_cast<ShuffleVectorInst>(Trunc.getOperand (0 ));
709709 if (Shuf && Shuf->hasOneUse () && match (Shuf->getOperand (1 ), m_Undef ()) &&
710710 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 ())) {
713714 // trunc (shuf X, Undef, SplatMask) --> shuf (trunc X), Poison, SplatMask
714715 // 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 *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 ());
722720 }
723721
724722 return nullptr ;
0 commit comments