[llvm] [VPlan] Introduce ExitPhi VPInstruction, use to create phi for FOR. (PR #94760)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 8 06:00:58 PDT 2024


================
@@ -8635,6 +8604,49 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
          "VPBasicBlock");
   RecipeBuilder.fixHeaderPhis();
 
+  auto *MiddleVPBB =
+      cast<VPBasicBlock>(Plan->getVectorLoopRegion()->getSingleSuccessor());
+
+  VPBasicBlock *ScalarPH = nullptr;
+  for (VPBlockBase *Succ : MiddleVPBB->getSuccessors()) {
+    auto *VPBB = dyn_cast<VPBasicBlock>(Succ);
+    if (VPBB && !isa<VPIRBasicBlock>(VPBB)) {
+      ScalarPH = VPBB;
+      break;
+    }
----------------
ayalz wrote:

Successors of MiddleVPBB must be VPBB's, so suffice to do
```suggestion
    if (isa<VPIRBasicBlock>(Succ))
      continue;
    assert(!ScalarPH && "Two candidates for ScalarPH?");
    ScalarPH = cast<VPBasicBlock>(Succ);
```

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


More information about the llvm-commits mailing list