[llvm] r353428 - [DAG] Cleanup of unused node in SimplifySelectCC.
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 7 09:37:54 PST 2019
Couldn't we simplify this before it's ever created instead of deleting
later?
Ie, we have things like "FoldBUILD_VECTOR()" and "FoldCONCAT_VECTORS()" in
SelectionDAG::getNode(), but no similar simplifications for ISD::SELECT_CC.
On Thu, Feb 7, 2019 at 10:13 AM Nirav Dave via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: niravd
> Date: Thu Feb 7 09:13:55 2019
> New Revision: 353428
>
> URL: http://llvm.org/viewvc/llvm-project?rev=353428&view=rev
> Log:
> [DAG] Cleanup of unused node in SimplifySelectCC.
>
> Modified:
> llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=353428&r1=353427&r2=353428&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Thu Feb 7
> 09:13:55 2019
> @@ -18660,14 +18660,21 @@ SDValue DAGCombiner::SimplifySelectCC(co
> auto *N3C = dyn_cast<ConstantSDNode>(N3.getNode());
>
> // Determine if the condition we're dealing with is constant.
> - SDValue SCC = SimplifySetCC(getSetCCResultType(CmpOpVT), N0, N1, CC, DL,
> - false);
> - if (SCC.getNode()) AddToWorklist(SCC.getNode());
> -
> - if (auto *SCCC = dyn_cast_or_null<ConstantSDNode>(SCC.getNode())) {
> - // fold select_cc true, x, y -> x
> - // fold select_cc false, x, y -> y
> - return !SCCC->isNullValue() ? N2 : N3;
> + if (SDValue SCC =
> + SimplifySetCC(getSetCCResultType(CmpOpVT), N0, N1, CC, DL,
> false)) {
> + AddToWorklist(SCC.getNode());
> + if (auto *SCCC = dyn_cast<ConstantSDNode>(SCC.getNode())) {
> + // fold select_cc true, x, y -> x
> + // fold select_cc false, x, y -> y
> + bool isNull = SCCC->isNullValue();
> + SDValue RV = isNull ? N3 : N2;
> + // Delete SCC if we don't use it.
> + if (SCCC != RV.getNode())
> + recursivelyDeleteUnusedNodes(SCCC);
> + return RV;
> + }
> + // Don't combine. Cleanup SCC.
> + recursivelyDeleteUnusedNodes(SCC.getNode());
> }
>
> if (SDValue V =
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190207/9345157a/attachment.html>
More information about the llvm-commits
mailing list