[llvm] [VPlan] Simplify live-ins early using SCEV. (PR #155304)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 4 13:08:20 PDT 2025
================
@@ -528,12 +529,30 @@ static void addInitialSkeleton(VPlan &Plan, Type *InductionTy, DebugLoc IVDL,
createExtractsForLiveOuts(Plan, MiddleVPBB);
}
+static void simplifyPlanWithSCEV(VPlan &Plan, ScalarEvolution &SE) {
+ auto SimplifyWithSCEV = [&](VPValue *VPV) -> VPValue * {
+ Value *UV = VPV->getUnderlyingValue();
+ if (!UV || !SE.isSCEVable(UV->getType()))
+ return nullptr;
+ auto *S = SE.getSCEV(UV);
+ if (auto *C = dyn_cast<SCEVConstant>(S))
+ return Plan.getOrAddLiveIn(C->getValue());
+ return nullptr;
+ };
+
+ for (VPValue *LiveIn : Plan.getLiveIns()) {
+ if (auto *Simp = SimplifyWithSCEV(LiveIn))
+ LiveIn->replaceAllUsesWith(Simp);
----------------
artagnon wrote:
```suggestion
if (VPValue *C = SimplifyWithSCEV(LiveIn))
LiveIn->replaceAllUsesWith(C);
```
?
https://github.com/llvm/llvm-project/pull/155304
More information about the llvm-commits
mailing list