@@ -7651,25 +7651,26 @@ static bool isGuaranteedNotToBeUndefOrPoison(
76517651 return true ;
76527652 }
76537653
7654- if (const auto *PN = dyn_cast<PHINode>(V)) {
7655- unsigned Num = PN->getNumIncomingValues ();
7656- bool IsWellDefined = true ;
7657- for (unsigned i = 0 ; i < Num; ++i) {
7658- if (PN == PN->getIncomingValue (i))
7659- continue ;
7660- auto *TI = PN->getIncomingBlock (i)->getTerminator ();
7661- if (!isGuaranteedNotToBeUndefOrPoison (PN->getIncomingValue (i), AC, TI,
7662- DT, Depth + 1 , Kind)) {
7663- IsWellDefined = false ;
7664- break ;
7654+ if (!::canCreateUndefOrPoison (Opr, Kind,
7655+ /* ConsiderFlagsAndMetadata=*/ true )) {
7656+ if (const auto *PN = dyn_cast<PHINode>(V)) {
7657+ unsigned Num = PN->getNumIncomingValues ();
7658+ bool IsWellDefined = true ;
7659+ for (unsigned i = 0 ; i < Num; ++i) {
7660+ if (PN == PN->getIncomingValue (i))
7661+ continue ;
7662+ auto *TI = PN->getIncomingBlock (i)->getTerminator ();
7663+ if (!isGuaranteedNotToBeUndefOrPoison (PN->getIncomingValue (i), AC, TI,
7664+ DT, Depth + 1 , Kind)) {
7665+ IsWellDefined = false ;
7666+ break ;
7667+ }
76657668 }
7666- }
7667- if (IsWellDefined)
7669+ if (IsWellDefined)
7670+ return true ;
7671+ } else if (all_of (Opr->operands (), OpCheck))
76687672 return true ;
7669- } else if (!::canCreateUndefOrPoison (Opr, Kind,
7670- /* ConsiderFlagsAndMetadata*/ true ) &&
7671- all_of (Opr->operands (), OpCheck))
7672- return true ;
7673+ }
76737674 }
76747675
76757676 if (auto *I = dyn_cast<LoadInst>(V))
0 commit comments