@@ -600,8 +600,8 @@ static Value *getMask(Value *WideMask, unsigned Factor,
600600
601601bool InterleavedAccessImpl::lowerDeinterleaveIntrinsic (
602602 IntrinsicInst *DI, SmallSetVector<Instruction *, 32 > &DeadInsts) {
603- Value *LoadedVal = DI->getOperand (0 );
604- if (!LoadedVal->hasOneUse ())
603+ Instruction *LoadedVal = dyn_cast<Instruction>( DI->getOperand (0 ) );
604+ if (!LoadedVal || !LoadedVal ->hasOneUse ())
605605 return false ;
606606
607607 auto *LI = dyn_cast<LoadInst>(LoadedVal);
@@ -645,26 +645,27 @@ bool InterleavedAccessImpl::lowerDeinterleaveIntrinsic(
645645 }
646646
647647 // Try and match this with target specific intrinsics.
648- if (!TLI->lowerDeinterleaveIntrinsicToLoad (cast<Instruction>(LoadedVal), Mask,
649- DI))
648+ if (!TLI->lowerDeinterleaveIntrinsicToLoad (LoadedVal, Mask, DI))
650649 return false ;
651650
652651 DeadInsts.insert (DI);
653652 // We now have a target-specific load, so delete the old one.
654- DeadInsts.insert (cast<Instruction>( LoadedVal) );
653+ DeadInsts.insert (LoadedVal);
655654 return true ;
656655}
657656
658657bool InterleavedAccessImpl::lowerInterleaveIntrinsic (
659- IntrinsicInst *II, SmallSetVector<Instruction *, 32 > &DeadInsts) {
660- if (!II->hasOneUse ())
658+ IntrinsicInst *IntII, SmallSetVector<Instruction *, 32 > &DeadInsts) {
659+ if (!IntII->hasOneUse ())
660+ return false ;
661+ Instruction *StoredBy = dyn_cast<Instruction>(IntII->user_back ());
662+ if (!StoredBy)
661663 return false ;
662- Value *StoredBy = II->user_back ();
663664 if (!isa<StoreInst, VPIntrinsic>(StoredBy))
664665 return false ;
665666
666- SmallVector<Value *, 8 > InterleaveValues (II ->args ());
667- const unsigned Factor = getInterleaveIntrinsicFactor (II ->getIntrinsicID ());
667+ SmallVector<Value *, 8 > InterleaveValues (IntII ->args ());
668+ const unsigned Factor = getInterleaveIntrinsicFactor (IntII ->getIntrinsicID ());
668669 assert (Factor && " unexpected interleave intrinsic" );
669670
670671 Value *Mask = nullptr ;
@@ -679,24 +680,23 @@ bool InterleavedAccessImpl::lowerInterleaveIntrinsic(
679680 return false ;
680681
681682 LLVM_DEBUG (dbgs () << " IA: Found a vp.store with interleave intrinsic "
682- << *II << " and factor = " << Factor << " \n " );
683+ << *IntII << " and factor = " << Factor << " \n " );
683684 } else {
684685 auto *SI = cast<StoreInst>(StoredBy);
685686 if (!SI->isSimple ())
686687 return false ;
687688
688- LLVM_DEBUG (dbgs () << " IA: Found a store with interleave intrinsic " << *II
689- << " and factor = " << Factor << " \n " );
689+ LLVM_DEBUG (dbgs () << " IA: Found a store with interleave intrinsic "
690+ << *IntII << " and factor = " << Factor << " \n " );
690691 }
691692
692693 // Try and match this with target specific intrinsics.
693- if (!TLI->lowerInterleaveIntrinsicToStore (cast<Instruction>(StoredBy), Mask,
694- InterleaveValues))
694+ if (!TLI->lowerInterleaveIntrinsicToStore (StoredBy, Mask, InterleaveValues))
695695 return false ;
696696
697697 // We now have a target-specific store, so delete the old one.
698- DeadInsts.insert (cast<Instruction>( StoredBy) );
699- DeadInsts.insert (II );
698+ DeadInsts.insert (StoredBy);
699+ DeadInsts.insert (IntII );
700700 return true ;
701701}
702702
0 commit comments