@@ -634,37 +634,28 @@ getVectorDeinterleaveFactor(IntrinsicInst *II,
634634// mask.
635635static Value *getMask (Value *WideMask, unsigned Factor,
636636 VectorType *LeafValueTy) {
637- Value *MaskVal = nullptr ;
638-
639637 using namespace llvm ::PatternMatch;
640638 if (auto *IMI = dyn_cast<IntrinsicInst>(WideMask)) {
641639 SmallVector<Value *, 8 > Operands;
642640 SmallVector<Instruction *, 8 > DeadInsts;
643641 if (getVectorInterleaveFactor (IMI, Operands, DeadInsts)) {
644642 assert (!Operands.empty ());
645643 if (Operands.size () == Factor && llvm::all_equal (Operands))
646- MaskVal = Operands[0 ];
644+ return Operands[0 ];
647645 }
648646 }
649647
650648 if (match (WideMask, m_AllOnes ())) {
651- // Scale the vector length.
649+ // Scale the vector length of all-ones mask .
652650 ElementCount OrigEC =
653651 cast<VectorType>(WideMask->getType ())->getElementCount ();
654- MaskVal =
655- ConstantVector::getSplat (OrigEC.divideCoefficientBy (Factor),
656- cast<Constant>(WideMask)->getSplatValue ());
657- }
658-
659- if (MaskVal) {
660- // Check if the vector length of mask matches that of the leaf values.
661- auto *MaskTy = cast<VectorType>(MaskVal->getType ());
662- if (!MaskTy->getElementType ()->isIntegerTy (/* Bitwidth=*/ 1 ) ||
663- MaskTy->getElementCount () != LeafValueTy->getElementCount ())
652+ if (OrigEC.getKnownMinValue () % Factor)
664653 return nullptr ;
654+ return ConstantVector::getSplat (OrigEC.divideCoefficientBy (Factor),
655+ cast<Constant>(WideMask)->getSplatValue ());
665656 }
666657
667- return MaskVal ;
658+ return nullptr ;
668659}
669660
670661bool InterleavedAccessImpl::lowerDeinterleaveIntrinsic (
0 commit comments