[llvm] [VPlan] Connect (MemRuntime|SCEV)Check blocks as VPlan transform (NFC). (PR #143879)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 5 12:25:02 PDT 2025


================
@@ -7612,11 +7512,21 @@ EpilogueVectorizerEpilogueLoop::createEpilogueVectorizedLoopSkeleton() {
   EPI.EpilogueIterationCountCheck->getTerminator()->replaceUsesOfWith(
       VecEpilogueIterationCountCheck, LoopScalarPreHeader);
 
-  if (EPI.SCEVSafetyCheck)
-    EPI.SCEVSafetyCheck->getTerminator()->replaceUsesOfWith(
+  // Retrieve blocks with SCEV and memory runtime checks, if they have been
+  // connected to the CFG, otherwise they are unused and will be deleted. Their
+  // terminators and phis using them need adjusting below.
+  BasicBlock *SCEVCheckBlock = RTChecks.getSCEVCheckBlock();
+  if (SCEVCheckBlock && pred_empty(SCEVCheckBlock))
+    SCEVCheckBlock = nullptr;
+  BasicBlock *MemCheckBlock = RTChecks.getMemCheckBlock();
+  if (MemCheckBlock && pred_empty(MemCheckBlock))
+    MemCheckBlock = nullptr;
+
+  if (SCEVCheckBlock)
----------------
ayalz wrote:

```suggestion
  if (SCEVCheckBlock && !pred_empty(SCEVCheckBlock))
```
although the latter case is unclear as noted above.

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


More information about the llvm-commits mailing list