[InstCombine] return the result of the GEP of PHI transformation early
authorDanila Malyutin <dmalyutin@azul.com>
Wed, 14 Dec 2022 10:31:15 +0000 (13:31 +0300)
committerDanila Malyutin <dmalyutin@azul.com>
Wed, 14 Dec 2022 11:56:38 +0000 (14:56 +0300)
Without this change this function could return nullptr if no further
transformation took place making InstCombine pass incorrectly report no
IR changes preventing analyses invalidation.

Differential Revision: https://reviews.llvm.org/D140004

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

index 38a79f0..1d34463 100644 (file)
@@ -2420,8 +2420,7 @@ Instruction *InstCombinerImpl::visitGetElementPtrInst(GetElementPtrInst &GEP) {
     }
 
     NewGEP->insertAt(GEP.getParent(), GEP.getParent()->getFirstInsertionPt());
-    replaceOperand(GEP, 0, NewGEP);
-    PtrOp = NewGEP;
+    return replaceOperand(GEP, 0, NewGEP);
   }
 
   if (auto *Src = dyn_cast<GEPOperator>(PtrOp))