[llvm] [InstCombine] Push freeze through non-recurrence PHIs (PR #157678)

Cullen Rhodes via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 10 02:26:21 PDT 2025


================
@@ -5070,7 +5078,10 @@ InstCombinerImpl::pushFreezeToPreventPoisonFromPropagating(FreezeInst &OrigFI) {
         return nullptr;
 
       auto *UserI = cast<Instruction>(U->getUser());
-      Builder.SetInsertPoint(UserI);
+      if (auto *PN = dyn_cast<PHINode>(UserI))
+        Builder.SetInsertPoint(PN->getIncomingBlock(*U)->getTerminator());
+      else
+        Builder.SetInsertPoint(UserI);
----------------
c-rhodes wrote:

> Can you please add a test where the phi input is an invoke result? It won't work in that case.
> 
> Also similar to the other PR, we need to be careful about multi-edges here.

Added test cases for both of these where it was crashing, now fixed.

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


More information about the llvm-commits mailing list