Skip to content

Conversation

madhur13490
Copy link
Contributor

This reverts commit 1d398a9.

@madhur13490
Copy link
Contributor Author

There can be cases where this is broken. Will reattempt.

@llvmbot
Copy link
Member

llvmbot commented Jul 17, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Madhur Amilkanthwar (madhur13490)

Changes

This reverts commit 1d398a9.


Full diff: https://github.com/llvm/llvm-project/pull/149270.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/Scalar/GVN.cpp (+6-9)
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index affae41ed2c83..8bff458f88bb9 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -2367,15 +2367,12 @@ uint32_t GVNPass::ValueTable::phiTranslateImpl(const BasicBlock *Pred,
   // See if we can refine the value number by looking at the PN incoming value
   // for the given predecessor.
   if (PHINode *PN = NumberingPhi[Num]) {
-    if (PN->getParent() != PhiBlock)
-      return Num;
-
-    for (unsigned I = 0; I != PN->getNumIncomingValues(); ++I) {
-      if (PN->getIncomingBlock(I) != Pred)
-        continue;
-      if (uint32_t TransVal = lookup(PN->getIncomingValue(I), false))
-        return TransVal;
-    }
+    if (PN->getParent() == PhiBlock)
+      for (unsigned I = 0; I != PN->getNumIncomingValues(); ++I)
+        if (PN->getIncomingBlock(I) == Pred)
+          if (uint32_t TransVal = lookup(PN->getIncomingValue(I), false))
+            return TransVal;
+    return Num;
   }
 
   if (BasicBlock *BB = NumberingBB[Num]) {

@madhur13490 madhur13490 merged commit 8b553c4 into llvm:main Jul 17, 2025
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants