[llvm] [LoopFusion] Remove DT edge from Extiblock to ExitBlockSuc (PR #193641)
Afonso Rafael via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 23 02:37:31 PDT 2026
https://github.com/Alf0nso updated https://github.com/llvm/llvm-project/pull/193641
>From 7a6374629d550de6d067fd7f2bc67dcab55943bf Mon Sep 17 00:00:00 2001
From: Afonso Rafael <afonsorafael at sapo.pt>
Date: Thu, 23 Apr 2026 00:11:50 +0000
Subject: [PATCH] [LoopFusion] Remove DT edge from Extiblock to ExitBlockSuc
This patch fixes the following assertion failure:
https://www.godbolt.org/z/ejEhYchPq
To remove the node, it cannot have successors, if this edge is not
removed, when applying the updates to the DT the following assertion
will appear:
"Assertion `Node->isLeaf() && "Node is not a leaf node."' failed"
This assertion does not always fail because before applying the
updates on the "GenericDomTreeContruction", "ApplyUpdates" function it
runs CalculateFromScratch on some situations:
// Make unittests of the incremental algorithm work
if (DT.DomTreeNodes.size() <= 100) {
if (BUI.NumLegalized > DT.DomTreeNodes.size())
CalculateFromScratch(DT, &BUI);
} else if (BUI.NumLegalized > DT.DomTreeNodes.size() / 40)
CalculateFromScratch(DT, &BUI);
---
llvm/lib/Transforms/Scalar/LoopFuse.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/llvm/lib/Transforms/Scalar/LoopFuse.cpp b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
index be543062670c6..6de3fc0174d7d 100644
--- a/llvm/lib/Transforms/Scalar/LoopFuse.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
@@ -1818,6 +1818,8 @@ struct LoopFuser {
DominatorTree::Insert, FC0GuardBlock, FC1NonLoopBlock));
if (FC0.Peeled) {
+ TreeUpdates.emplace_back(DominatorTree::UpdateType(
+ DominatorTree::Delete, FC0.ExitBlock, FC0ExitBlockSuccessor));
// Remove the Block after the ExitBlock of FC0
TreeUpdates.emplace_back(DominatorTree::UpdateType(
DominatorTree::Delete, FC0ExitBlockSuccessor, FC1GuardBlock));
More information about the llvm-commits
mailing list