[llvm] [SandboxVec][LoadStoreVec] Vectorize load seed chains (PR #215944)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 15 18:01:57 PDT 2026


================
@@ -36,76 +36,107 @@ std::optional<Type *> LoadStoreVec::canVectorize(ArrayRef<Instruction *> Bndl,
     return std::nullopt;
 
   // Check scheduling.
-  if (!Sched.trySchedule(Bndl))
+  if (!Sched->trySchedule(Bndl))
     return std::nullopt;
 
   return VecUtils::getCombinedVectorTypeFor(Bndl, *DL);
 }
 
-void LoadStoreVec::tryEraseDeadInstrs(ArrayRef<Instruction *> Stores,
-                                      ArrayRef<Value *> Operands) {
-  SmallPtrSet<Instruction *, 8> DeadCandidates;
-  for (auto *SI : Stores) {
-    if (auto *PtrI =
-            dyn_cast<Instruction>(cast<StoreInst>(SI)->getPointerOperand()))
-      DeadCandidates.insert(PtrI);
-    SI->eraseFromParent();
-  }
-  for (auto *Op : Operands) {
-    if (auto *LI = dyn_cast<LoadInst>(Op)) {
-      if (auto *PtrI =
-              dyn_cast<Instruction>(cast<LoadInst>(LI)->getPointerOperand()))
-        DeadCandidates.insert(PtrI);
-      cast<LoadInst>(LI)->eraseFromParent();
-    }
-  }
-  for (auto *PtrI : DeadCandidates)
-    if (!PtrI->hasNUsesOrMore(1))
-      PtrI->eraseFromParent();
-}
-
-void LoadStoreVec::saveIR(Region &Rgn) {
-  SavedRgn = &Rgn;
-  const auto &SB = cast<RegionWithScore>(Rgn).getScoreboard();
+void LoadStoreVec::saveIR(Region &R) {
+  Rgn = &R;
+  const auto &SB = cast<RegionWithScore>(Rgn)->getScoreboard();
   CostBefore = SB.getAfterCost() - SB.getBeforeCost();
-  Rgn.getContext().save();
+  Rgn->getContext().save();
 }
 
 bool LoadStoreVec::acceptOrRevert() {
-  auto &Ctx = SavedRgn->getContext();
-  const auto &SB = cast<RegionWithScore>(*SavedRgn).getScoreboard();
+  auto &SavedCtx = Rgn->getContext();
----------------
vporpo wrote:

SavedCtx -> Ctx

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


More information about the llvm-commits mailing list