@@ -973,11 +973,18 @@ static VPValue *tryToFoldLiveIns(VPSingleDefRecipe &R,
973973 ArrayRef<VPValue *> Operands,
974974 const DataLayout &DL,
975975 VPTypeAnalysis &TypeInfo) {
976- auto FoldIROperands = [&R, &DL, &TypeInfo](ArrayRef<Value *> Ops ) -> Value * {
976+ auto FoldToIRValue = [&]( ) -> Value * {
977977 auto OpcodeOrIID = getOpcodeOrIntrinsicID (&R);
978978 if (!OpcodeOrIID)
979979 return nullptr ;
980980
981+ SmallVector<Value *, 4 > Ops;
982+ for (VPValue *Op : Operands) {
983+ if (!Op->isLiveIn () || !Op->getLiveInIRValue ())
984+ return nullptr ;
985+ Ops.push_back (Op->getLiveInIRValue ());
986+ }
987+
981988 InstSimplifyFolder Folder (DL);
982989 if (OpcodeOrIID->first ) {
983990 if (R.getNumOperands () != 2 )
@@ -1010,7 +1017,7 @@ static VPValue *tryToFoldLiveIns(VPSingleDefRecipe &R,
10101017 auto &RFlags = cast<VPRecipeWithIRFlags>(R);
10111018 auto *GEP = cast<GetElementPtrInst>(RFlags.getUnderlyingInstr ());
10121019 return Folder.FoldGEP (GEP->getSourceElementType (), Ops[0 ],
1013- Ops. drop_front ( ), RFlags.getGEPNoWrapFlags ());
1020+ drop_begin (Ops ), RFlags.getGEPNoWrapFlags ());
10141021 }
10151022 case VPInstruction::PtrAdd:
10161023 case VPInstruction::WidePtrAdd:
@@ -1026,14 +1033,7 @@ static VPValue *tryToFoldLiveIns(VPSingleDefRecipe &R,
10261033 return nullptr ;
10271034 };
10281035
1029- SmallVector<Value *, 4 > Ops;
1030- for (VPValue *Op : Operands) {
1031- if (!Op->isLiveIn () || !Op->getLiveInIRValue ())
1032- return nullptr ;
1033- Ops.push_back (Op->getLiveInIRValue ());
1034- }
1035-
1036- if (Value *V = FoldIROperands (Ops))
1036+ if (Value *V = FoldToIRValue ())
10371037 return R.getParent ()->getPlan ()->getOrAddLiveIn (V);
10381038 return nullptr ;
10391039}
0 commit comments