[llvm] [VPlan] Reuse mask of immediate dominator in VPlanPredicator (PR #185595)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 11 01:10:21 PDT 2026


================
@@ -133,12 +136,13 @@ void VPPredicator::createBlockInMask(VPBasicBlock *VPBB) {
   // Start inserting after the block's phis, which be replaced by blends later.
   Builder.setInsertPoint(VPBB, VPBB->getFirstNonPhi());
 
-  // Reuse the mask of the header if the VPBB post-dominates the header.
-  // TODO: Generalize to reuse mask of immediate dominator.
-  VPBasicBlock *Header =
-      VPBB->getPlan()->getVectorLoopRegion()->getEntryBasicBlock();
-  if (VPPDT.properlyDominates(VPBB, Header)) {
-    setBlockInMask(VPBB, getBlockInMask(Header));
+  // Reuse the mask of the immediate dominator if the VPBB post-dominates the
+  // immediate dominator.
+  auto *IDom = VPDT.getNode(VPBB)->getIDom();
----------------
lukel97 wrote:

Nit, use `VPBasicBlock *IDom`?

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


More information about the llvm-commits mailing list