[llvm] [InstCombine] Push freeze through non-recurrence PHIs (PR #157678)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 22 01:45:56 PDT 2025
================
@@ -5042,10 +5042,29 @@ InstCombinerImpl::pushFreezeToPreventPoisonFromPropagating(FreezeInst &OrigFI) {
// Op1.fr = Freeze(Op1)
// ... = Inst(Op1.fr, NonPoisonOps...)
- auto CanPushFreeze = [](Value *V) {
- if (!isa<Instruction>(V) || isa<PHINode>(V))
+ auto CanPushFreeze = [this](Value *V) {
+ if (!isa<Instruction>(V))
return false;
+ if (auto *PN = dyn_cast<PHINode>(V)) {
+ BasicBlock *BB = PN->getParent();
+ SmallPtrSet<BasicBlock *, 8> VisitedBBs;
+ for (Use &U : PN->incoming_values()) {
+ BasicBlock *InBB = PN->getIncomingBlock(U);
+ // We can't move freeze if the start value is the result of a
+ // terminator (e.g. an invoke).
+ if (auto *OpI = dyn_cast<Instruction>(U)) {
+ if (OpI->isTerminator())
+ return false;
+ }
+
+ if (DT.dominates(BB, InBB) || isBackEdge(InBB, BB) ||
----------------
nikic wrote:
Is the dominates check here still needed?
https://github.com/llvm/llvm-project/pull/157678
More information about the llvm-commits
mailing list