[llvm] [VPlan] Recalculate VPDT in handleUncountableExitsWithSideEffects (PR #203233)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 11 03:11:18 PDT 2026


https://github.com/lukel97 created https://github.com/llvm/llvm-project/pull/203233

In the loop before we're modifying the CFG, but this invalidates the
dominator tree. We need to recalculate since we query it later on. I
can't really think of a test case for this, if anything using the
stale dominator tree with the extra branch will make the dominance
queries more conservative. But it's probably something we should fix.


>From 6c916678df65787d524558919cee233bf2329aa8 Mon Sep 17 00:00:00 2001
From: Luke Lau <luke at igalia.com>
Date: Thu, 11 Jun 2026 18:06:20 +0800
Subject: [PATCH] [VPlan] Recalculate VPDT in
 handleUncountableExitsWithSideEffects

In the loop before we're modifying the CFG, but this invalidates the
dominator tree. We need to recalculate since we query it later on. I
can't really think of a test case for this, if anything using the
stale dominator tree with the extra branch will make the dominance
queries more conservative. But it's probably something we should fix.
---
 llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 3fe8c84658c8f..cd0fddd4489d8 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -4250,6 +4250,8 @@ static bool handleUncountableExitsWithSideEffects(
     VPBlockUtils::disconnectBlocks(Exit.EarlyExitingVPBB, Exit.EarlyExitVPBB);
   }
 
+  VPDT.recalculate(Plan);
+
   // We can abandon a VPlan entirely if we return false here, so we shouldn't
   // crash if some earlier assumptions on scalar IR don't hold for the vplan
   // version of the loop.



More information about the llvm-commits mailing list