This is an archive of the discontinued LLVM Phabricator instance.

[DAG] Add initial SelectionDAG::canCreateUndefOrPoison support
ClosedPublic

Authored by RKSimon on Jul 27 2022, 9:56 AM.

Details

Summary

This patch adds basic support for a DAG variant of the canCreateUndefOrPoison call and updates DAGCombiner::visitFREEZE to use it, further Opcodes (including target specific Opcodes) can be handled when we have test coverage.

So far, I've left visitFREEZE to just use this for unary nodes (which currently means the existing BITCAST/FREEZE cases) - later patches will add other unary opcodes (with test coverage) and we can also refactor visitFREEZE to support a general number of operands like we do in InstCombinerImpl::pushFreezeToPreventPoisonFromPropagating.

I'm not aware of any vector test freeze coverage so the DemandedElts (and the Depth) args are not being used yet - but they are in place. Similarly we will be able to handle poison generating SDNodeFlags as and when it becomes an issue.

Part of the work for D106675 / PR50468

Diff Detail

Event Timeline

RKSimon created this revision.Jul 27 2022, 9:56 AM
RKSimon requested review of this revision.Jul 27 2022, 9:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2022, 9:56 AM

The logic looks good to me, but it would be great if the patch gets approvals from people familiar with SelectionDag.

RKSimon updated this revision to Diff 448364.Jul 28 2022, 9:36 AM
RKSimon edited the summary of this revision. (Show Details)

Add missing hasOneUse check and add PoisonOnly = false default argument to match isGuaranteedNotToBeUndefOrPoison

spatel accepted this revision.Aug 8 2022, 5:52 AM

LGTM

This revision is now accepted and ready to land.Aug 8 2022, 5:52 AM
This revision was landed with ongoing or failed builds.Aug 8 2022, 7:16 AM
This revision was automatically updated to reflect the committed changes.