[llvm] [NewGVN] Prevent cyclic dependencies by ensuring Leader has min RPO number (PR #82110)

Alina Sbirlea via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 27 07:45:16 PST 2024


================
@@ -731,7 +739,13 @@ class NewGVN {
 
   // Congruence class handling.
   CongruenceClass *createCongruenceClass(Value *Leader, const Expression *E) {
-    auto *result = new CongruenceClass(NextCongruenceNum++, Leader, E);
+    unsigned LeaderDFS = 0;
+    if (!Leader)
+      LeaderDFS = ~0;
+    else if (auto *I = dyn_cast<Instruction>(Leader))
+      LeaderDFS = InstrToDFSNum(I);
+    auto *result =
+        new CongruenceClass(NextCongruenceNum++, {Leader, LeaderDFS}, E);
----------------
alinas wrote:

Can you add a comment on why all non-instructions Values initialize to 0? ConstantValue?

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


More information about the llvm-commits mailing list