[llvm] [GVN][NFC] Use early return in phiTranslateImpl() (PR #149268)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 17 01:24:40 PDT 2025
================
@@ -2367,12 +2367,15 @@ 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)
- 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 (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;
+ }
----------------
fhahn wrote:
previously we would `return Num;` if no translated incoming value could be found, now we fall through.
https://github.com/llvm/llvm-project/pull/149268
More information about the llvm-commits
mailing list