Skip to content

Commit 0ed947b

Browse files
artagnonDebadri Basak
authored andcommitted
[VPlan] Improve getOrCreateVPValueForSCEVExpr (NFC) (llvm#165699)
Use early exit in getOrCreateVPValueForSCEVExpr.
1 parent dbae0c2 commit 0ed947b

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

llvm/lib/Transforms/Vectorize/VPlanUtils.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,17 @@ bool vputils::onlyScalarValuesUsed(const VPValue *Def) {
3232
}
3333

3434
VPValue *vputils::getOrCreateVPValueForSCEVExpr(VPlan &Plan, const SCEV *Expr) {
35-
VPValue *Expanded = nullptr;
3635
if (auto *E = dyn_cast<SCEVConstant>(Expr))
37-
Expanded = Plan.getOrAddLiveIn(E->getValue());
38-
else {
39-
auto *U = dyn_cast<SCEVUnknown>(Expr);
40-
// Skip SCEV expansion if Expr is a SCEVUnknown wrapping a non-instruction
41-
// value. Otherwise the value may be defined in a loop and using it directly
42-
// will break LCSSA form. The SCEV expansion takes care of preserving LCSSA
43-
// form.
44-
if (U && !isa<Instruction>(U->getValue())) {
45-
Expanded = Plan.getOrAddLiveIn(U->getValue());
46-
} else {
47-
Expanded = new VPExpandSCEVRecipe(Expr);
48-
Plan.getEntry()->appendRecipe(Expanded->getDefiningRecipe());
49-
}
50-
}
36+
return Plan.getOrAddLiveIn(E->getValue());
37+
// Skip SCEV expansion if Expr is a SCEVUnknown wrapping a non-instruction
38+
// value. Otherwise the value may be defined in a loop and using it directly
39+
// will break LCSSA form. The SCEV expansion takes care of preserving LCSSA
40+
// form.
41+
auto *U = dyn_cast<SCEVUnknown>(Expr);
42+
if (U && !isa<Instruction>(U->getValue()))
43+
return Plan.getOrAddLiveIn(U->getValue());
44+
auto *Expanded = new VPExpandSCEVRecipe(Expr);
45+
Plan.getEntry()->appendRecipe(Expanded);
5146
return Expanded;
5247
}
5348

0 commit comments

Comments
 (0)