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

Cullen Rhodes via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 24 05:03:17 PST 2025


================
@@ -5049,13 +5072,25 @@ InstCombinerImpl::pushFreezeToPreventPoisonFromPropagating(FreezeInst &OrigFI) {
   while (!Worklist.empty()) {
     auto *U = Worklist.pop_back_val();
     Value *V = U->get();
+
+    if (auto *PN = dyn_cast<PHINode>(V)) {
+      if (FreezePhisVisited.contains(PN)) {
----------------
c-rhodes wrote:

I've simplified the change to introduce a cache as @paulwalker-arm suggested to restrict it to `pushFreezeToPreventPoisonFromPropagating`. It also now assumes it's ok to push a freeze thru the PHI if it's been done before. To be honest I'm not entirely sure if the cache could be invalidated somehow making this unsafe, @nikic would appreciate your expertise there. If so, the original cache I added shouldnt have this problem at least, or perhaps you have a better idea.

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


More information about the llvm-commits mailing list