[llvm] [InstCombine] Push freeze through non-recurrence PHIs (PR #157678)
Cullen Rhodes via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 26 08:12:51 PDT 2025
c-rhodes wrote:
Whilst doing some further testing I found 527.cam4_r in SPEC2017 is hanging with this patch. I see:
```
OrigUse->get() = <2 x i1> poison
OrigFI: %.fr91682 = freeze <2 x i1> poison
OrigUse->get() = <2 x i1> poison
OrigFI: %188 = freeze <2 x i1> %broadcast.splat2369
OrigUse->get() = %broadcast.splat2369 = shufflevector <2 x i1> %broadcast.splatinsert2368, <2 x i1> poison, <2 x i32> zeroinitializer
```
is repeated when dumping OrigFI/OrigUse in `pushFreezeToPreventPoisonFromPropagating`, so I added check:
```diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 6004feb1d885..be983ed63daf 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -5026,6 +5026,9 @@ InstCombinerImpl::pushFreezeToPreventPoisonFromPropagating(FreezeInst &OrigFI) {
if (U == OrigUse)
return nullptr;
+ if (match(V, m_Poison()))
+ return nullptr;
+
auto *UserI = cast<Instruction>(U->getUser());
if (auto *PN = dyn_cast<PHINode>(UserI))
Builder.SetInsertPoint(PN->getIncomingBlock(*U)->getTerminator());
```
which fixes it, but still trying to write a test case. I did isolate the function in cam4 and attempt to reduce it will llvm-reduce, but just get testcases that take exactly N seconds to compile.
I also collected data on the # of freezes in SPEC2017 (Ofast, LTO) after this patch and there's a ~13% increase. #154336 also caused an increase of ~27%. Although as previously mentioned https://github.com/llvm/llvm-project/pull/154336#issuecomment-3201408296, I'm not convinced this is a particularly useful metric, but just wanted to share this.
https://github.com/llvm/llvm-project/pull/157678
More information about the llvm-commits
mailing list