Skip to content

Commit e13db19

Browse files
committed
[VPlan] Early-return after const-folding
1 parent d2ddfec commit e13db19

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -938,14 +938,18 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo,
938938

939939
// Constant folding.
940940
VPConstantFolder Folder(DL, TypeInfo);
941-
TypeSwitch<VPRecipeBase *, void>(&R)
942-
.Case<VPInstruction, VPWidenRecipe, VPWidenCastRecipe, VPReplicateRecipe>(
943-
[&](auto *I) {
941+
if (TypeSwitch<VPRecipeBase *, bool>(&R)
942+
.Case<VPInstruction, VPWidenRecipe, VPWidenCastRecipe,
943+
VPReplicateRecipe>([&](auto *I) {
944944
VPlan *Plan = R.getParent()->getPlan();
945945
ArrayRef<VPValue *> Ops(I->op_begin(), I->op_end());
946-
if (Value *V = Folder.tryToConstantFold(R, I->getOpcode(), Ops))
946+
Value *V = Folder.tryToConstantFold(R, I->getOpcode(), Ops);
947+
if (V)
947948
R.getVPSingleValue()->replaceAllUsesWith(Plan->getOrAddLiveIn(V));
948-
});
949+
return V;
950+
})
951+
.Default([](auto *) { return false; }))
952+
return;
949953

950954
// VPScalarIVSteps can only be simplified after unrolling. VPScalarIVSteps for
951955
// part 0 can be replaced by their start value, if only the first lane is

0 commit comments

Comments
 (0)