[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
================
@@ -5042,10 +5042,33 @@ 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()) {
----------------
david-arm wrote:
You might be able to avoid the additional cost of a lookup in `getIncomingBlock` below by rewriting the loop like this:
```
for (unsigned I = 0; I < PN->getNumIncomingValues(); I++) {
Value *InV = PN->getIncomingValue(I);
BasicBlock *InBB = PN->getIncomingBlock(I);
}
```
https://github.com/llvm/llvm-project/pull/157678
More information about the llvm-commits
mailing list