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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 23 08:31:22 PDT 2025


================
@@ -5070,7 +5093,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());
----------------
nikic wrote:

Note that CanPushFreeze() is called on the use, while this is checking for the *user* being a phi node. Previously we could not have ended up with a phi user, as that would imply that we have pushed through a phi.

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


More information about the llvm-commits mailing list