[llvm] [LV] Compute SCEV for memcheck before unlinking (PR #160326)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 26 08:16:19 PDT 2025


================
@@ -2083,6 +2086,20 @@ Value *llvm::addRuntimeChecks(
           "stride.check");
       IsConflict = ChkBuilder.CreateOr(IsConflict, IsNegativeStride);
     }
+
+    if (AllChecksHoisted) {
----------------
david-arm wrote:

I'm not sure all these checks are necessary. Can't you just do a single check at the very end before we return from the function, i.e.

```
  auto *SE = Exp.getSE();
  auto *OuterLoop = TheLoop->getParentLoop();
  AllChecksHoisted = false;
  if (HoistRuntimeChecks && OuterLoop != nullptr)
    AllChecksHoisted = SE->isLoopInvariant(SE->getSCEV(MemoryRuntimeCheck));

  Exp.eraseDeadInstructions(MemoryRuntimeCheck);
  return MemoryRuntimeCheck;
```

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


More information about the llvm-commits mailing list