[llvm] [UnifyLoopExits] Never generate phis of only `undef` values (PR #99924)
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 22 12:39:27 PDT 2024
================
@@ -1909,22 +1909,29 @@ static void reconnectPhis(BasicBlock *Out, BasicBlock *GuardBlock,
auto NewPhi =
PHINode::Create(Phi->getType(), Incoming.size(),
Phi->getName() + ".moved", FirstGuardBlock->begin());
+ bool AllUndef = true;
for (auto *In : Incoming) {
Value *V = UndefValue::get(Phi->getType());
if (In == Out) {
V = NewPhi;
} else if (Phi->getBasicBlockIndex(In) != -1) {
V = Phi->removeIncomingValue(In, false);
+ AllUndef &= isa<UndefValue>(V);
}
NewPhi->addIncoming(V, In);
}
assert(NewPhi->getNumIncomingValues() == Incoming.size());
+ Value *NewV = NewPhi;
+ if (AllUndef) {
+ NewPhi->eraseFromParent();
+ NewV = UndefValue::get(Phi->getType());
----------------
jdoerfert wrote:
As of right now, this emits undef by default. We likely want to change both UndefValue::get to poison. Should I include that and track undef/poison separately?
https://github.com/llvm/llvm-project/pull/99924
More information about the llvm-commits
mailing list