[DAG] Add initial SelectionDAG::canCreateUndefOrPoison support
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Mon, 8 Aug 2022 14:15:56 +0000 (15:15 +0100)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Mon, 8 Aug 2022 14:16:06 +0000 (15:16 +0100)
commit9641a201a565346bfddfc02b13b2b583c056e61d
treea5b489f177672a5c26902918355a5b3640e5f476
parent59bb9e37c66bfbec6b2f0f7a07516adb6859acc3
[DAG] Add initial SelectionDAG::canCreateUndefOrPoison support

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

Differential Revision: https://reviews.llvm.org/D130646
llvm/include/llvm/CodeGen/SelectionDAG.h
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp