[llvm] [InstCombine] Opt phi(freeze(undef), C) -> phi(C, C) (PR #161181)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 1 00:05:55 PDT 2025


================
@@ -5190,6 +5217,10 @@ Instruction *InstCombinerImpl::visitFreeze(FreezeInst &I) {
       else if (match(U, m_c_Select(m_Specific(&I), m_Value(V)))) {
         if (!isGuaranteedNotToBeUndefOrPoison(V, &AC, &I, &DT))
           V = NullValue;
+      } else if (auto *PHI = dyn_cast<PHINode>(U)) {
+        Value *MaybeV = pickCommonConstantFromPHI(*PHI);
+        if (MaybeV)
----------------
nikic wrote:

You can combine the if + variable declaration.

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


More information about the llvm-commits mailing list