[llvm] [SCCIterator] Union tree by rank correctly (PR #86389)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 23 03:15:10 PDT 2024
https://github.com/XChy created https://github.com/llvm/llvm-project/pull/86389
Fixes #85975
>From 919c23fa4a6a144ef7157bbc1a38d56deca3c8cd Mon Sep 17 00:00:00 2001
From: XChy <xxs_chy at outlook.com>
Date: Sat, 23 Mar 2024 18:11:36 +0800
Subject: [PATCH] [SCCIterator] Union tree by rank correctly
---
llvm/include/llvm/ADT/SCCIterator.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/include/llvm/ADT/SCCIterator.h b/llvm/include/llvm/ADT/SCCIterator.h
index e743ae7c11edbc..3bd103c13f19f9 100644
--- a/llvm/include/llvm/ADT/SCCIterator.h
+++ b/llvm/include/llvm/ADT/SCCIterator.h
@@ -281,14 +281,14 @@ class scc_member_iterator {
if (G1 == G2)
return false;
- // Make the smaller rank tree a direct child or the root of high rank tree.
- if (G1->Rank < G1->Rank)
+ // Make the smaller rank tree a direct child of high rank tree.
+ if (G1->Rank < G2->Rank)
G1->Group = G2;
else {
G2->Group = G1;
// If the ranks are the same, increment root of one tree by one.
if (G1->Rank == G2->Rank)
- G2->Rank++;
+ G1->Rank++;
}
return true;
}
More information about the llvm-commits
mailing list