From: Craig Topper Date: Thu, 24 Nov 2016 21:48:52 +0000 (+0000) Subject: [DAGCombine] Teach DAG combine that if both inputs of a vselect are the same, then... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=670c05a5b24c84c8978e3cf5f15089552759b951;p=llvm [DAGCombine] Teach DAG combine that if both inputs of a vselect are the same, then the condition doesn't matter and the vselect can be removed. Selects with scalar condition already handle this correctly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287904 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index e3cab19733b..49e64903f46 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -5774,6 +5774,10 @@ SDValue DAGCombiner::visitVSELECT(SDNode *N) { SDValue N2 = N->getOperand(2); SDLoc DL(N); + // fold (vselect C, X, X) -> X + if (N1 == N2) + return N1; + // Canonicalize integer abs. // vselect (setg[te] X, 0), X, -X -> // vselect (setgt X, -1), X, -X ->