[DAG] isGuaranteedNotToBeUndefOrPoisonForTargetNode - add fallback implementation (#86125)

Allow targets to rely on TargetLowering::isGuaranteedNotToBeUndefOrPoisonForTargetNode to test nodes for canCreateUndefOrPoisonForTargetNode + all arguments are isGuaranteedNotToBeUndefOrPoison.

Targets can still perform this themselves for specific special case nodes (e.g. target shuffles).

Matches the fallback in SelectionDAG::isGuaranteedNotToBeUndefOrPoison
This commit is contained in:
Simon Pilgrim 2024-03-21 15:11:59 +00:00 committed by GitHub
parent 8d7a6e2fd8
commit e4fa2e3562
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View File

@ -5042,8 +5042,9 @@ bool SelectionDAG::isGuaranteedNotToBeUndefOrPoison(SDValue Op,
// If Op can't create undef/poison and none of its operands are undef/poison
// then Op is never undef/poison.
// NOTE: TargetNodes should handle this in themselves in
// isGuaranteedNotToBeUndefOrPoisonForTargetNode.
// NOTE: TargetNodes can handle this in themselves in
// isGuaranteedNotToBeUndefOrPoisonForTargetNode or let
// TargetLowering::isGuaranteedNotToBeUndefOrPoisonForTargetNode handle it.
return !canCreateUndefOrPoison(Op, PoisonOnly, /*ConsiderFlags*/ true,
Depth) &&
all_of(Op->ops(), [&](SDValue V) {

View File

@ -3786,7 +3786,15 @@ bool TargetLowering::isGuaranteedNotToBeUndefOrPoisonForTargetNode(
Op.getOpcode() == ISD::INTRINSIC_VOID) &&
"Should use isGuaranteedNotToBeUndefOrPoison if you don't know whether Op"
" is a target node!");
return false;
// If Op can't create undef/poison and none of its operands are undef/poison
// then Op is never undef/poison.
return !canCreateUndefOrPoisonForTargetNode(Op, DemandedElts, DAG, PoisonOnly,
/*ConsiderFlags*/ true, Depth) &&
all_of(Op->ops(), [&](SDValue V) {
return DAG.isGuaranteedNotToBeUndefOrPoison(V, PoisonOnly,
Depth + 1);
});
}
bool TargetLowering::canCreateUndefOrPoisonForTargetNode(