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

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 23 05:36:43 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());
----------------
david-arm wrote:

I'm not quite sure why this change is needed. Before this PR `CanPushFreeze` always returned false for PHI nodes and the existing `Builder.SetInsertPoint(UserI);` seemed to work perfectly fine. All that happens now is that we *sometimes* return false if it's a PHI node.

Is this fixing an existing bug?

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


More information about the llvm-commits mailing list