Skip to content

Commit a1b8530

Browse files
committed
[VPlan] Refactor to FoldToIRValue
1 parent 56f9d21 commit a1b8530

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)