[llvm] [VPlan] Simplify live-ins early using SCEV. (PR #155304)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 11 08:13:46 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);
----------------
fhahn wrote:

Updated to `VPValue *SimplifiedLiveIn`, thanks

https://github.com/llvm/llvm-project/pull/155304


More information about the llvm-commits mailing list