Let isGuaranteedNotToBeUndefOrPoison consider PHINode with constant values

This commit is contained in:
Juneyoung Lee 2020-02-04 16:46:54 +09:00
parent cd14b4a62b
commit 36272d5f00
1 changed files with 7 additions and 0 deletions

View File

@ -4522,6 +4522,13 @@ bool llvm::isGuaranteedNotToBeUndefOrPoison(const Value *V) {
if (isa<ConstantInt>(V) || isa<GlobalVariable>(V))
return true;
if (auto PN = dyn_cast<PHINode>(V)) {
if (llvm::all_of(PN->incoming_values(), [](const Use &U) {
return isa<ConstantInt>(U.get());
}))
return true;
}
return false;
}