[DAGCombine] Teach DAG combine that if both inputs of a vselect are the same, then...
authorCraig Topper <craig.topper@gmail.com>
Thu, 24 Nov 2016 21:48:52 +0000 (21:48 +0000)
committerCraig Topper <craig.topper@gmail.com>
Thu, 24 Nov 2016 21:48:52 +0000 (21:48 +0000)
Selects with scalar condition already handle this correctly.

llvm-svn: 287904

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index e3cab19..49e6490 100644 (file)
@@ -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 ->