summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-11-19 17:06:05 +0000
committerSanjay Patel <spatel@rotateright.com>2018-11-19 17:06:05 +0000
commitb25adf5edba0bfb487828600f4294702e695fdba (patch)
tree188a8c0e05583ccb9346be2ff843f8b97134629e /llvm/lib
parent22a04efcb0cfac222abfaec381406eff7e157ec6 (diff)
downloadbcm5719-llvm-b25adf5edba0bfb487828600f4294702e695fdba.tar.gz
bcm5719-llvm-b25adf5edba0bfb487828600f4294702e695fdba.zip
[SelectionDAG] simplify vector select with undef operand(s)
llvm-svn: 347227
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp5
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp12
2 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 31589fe586b..5510d9a9dab 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -7816,9 +7816,8 @@ SDValue DAGCombiner::visitVSELECT(SDNode *N) {
SDValue N2 = N->getOperand(2);
SDLoc DL(N);
- // fold (vselect C, X, X) -> X
- if (N1 == N2)
- return N1;
+ if (SDValue V = DAG.simplifySelect(N0, N1, N2))
+ return V;
// Canonicalize integer abs.
// vselect (setg[te] X, 0), X, -X ->
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 1a73a01cc49..d98c609ab3a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -5078,6 +5078,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
break;
}
case ISD::SELECT:
+ case ISD::VSELECT:
if (SDValue V = simplifySelect(N1, N2, N3))
return V;
break;
@@ -6790,11 +6791,18 @@ SDValue SelectionDAG::simplifySelect(SDValue Cond, SDValue T, SDValue F) {
if (F.isUndef())
return T;
- // fold (select true, T, F) -> T
- // fold (select false, T, F) -> F
+ // select true, T, F --> T
+ // select false, T, F --> F
if (auto *CondC = dyn_cast<ConstantSDNode>(Cond))
return CondC->isNullValue() ? F : T;
+ // TODO: This should simplify VSELECT with constant condition using something
+ // like this (but check boolean contents to be complete?):
+ // if (ISD::isBuildVectorAllOnes(Cond.getNode()))
+ // return T;
+ // if (ISD::isBuildVectorAllZeros(Cond.getNode()))
+ // return F;
+
// select ?, T, T --> T
if (T == F)
return T;
OpenPOWER on IntegriCloud