summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2017-10-17 18:14:48 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2017-10-17 18:14:48 +0000
commit654bbb3b0526f61882f212247864b1572ac339cd (patch)
treeb825e90598588161e24dcf5e5d9b01cb66ab1189
parent9e5751894d5f495fb62aa7d3aa6188af44b3a3f3 (diff)
downloadbcm5719-llvm-654bbb3b0526f61882f212247864b1572ac339cd.tar.gz
bcm5719-llvm-654bbb3b0526f61882f212247864b1572ac339cd.zip
[DAGCombine] Add SCALAR_TO_VECTOR undef handling to simplifyShuffleMask.
This allows us to simplify later visitVECTOR_SHUFFLE optimizations such as combineShuffleOfScalars. Noticed whilst working on D38696 llvm-svn: 316017
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 45967372d42..73b90666c56 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -15350,6 +15350,8 @@ static SDValue simplifyShuffleMask(ShuffleVectorSDNode *SVN, SDValue N0,
// TODO - handle more cases as required.
if (V.getOpcode() == ISD::BUILD_VECTOR)
return V.getOperand(Idx).isUndef();
+ if (V.getOpcode() == ISD::SCALAR_TO_VECTOR)
+ return (Idx != 0) || V.getOperand(0).isUndef();
return false;
};
@@ -15463,6 +15465,7 @@ static SDValue combineShuffleOfScalars(ShuffleVectorSDNode *SVN,
if (!N0->hasOneUse() || !N1->hasOneUse())
return SDValue();
+
// If only one of N1,N2 is constant, bail out if it is not ALL_ZEROS as
// discussed above.
if (!N1.isUndef()) {
@@ -15484,8 +15487,8 @@ static SDValue combineShuffleOfScalars(ShuffleVectorSDNode *SVN,
if (S.getOpcode() == ISD::BUILD_VECTOR) {
Op = S.getOperand(Idx);
} else if (S.getOpcode() == ISD::SCALAR_TO_VECTOR) {
- if (Idx == 0)
- Op = S.getOperand(0);
+ assert(Idx == 0 && "Unexpected SCALAR_TO_VECTOR operand index.");
+ Op = S.getOperand(0);
} else {
// Operand can't be combined - bail out.
return SDValue();
@@ -15501,6 +15504,7 @@ static SDValue combineShuffleOfScalars(ShuffleVectorSDNode *SVN,
Ops.push_back(Op);
}
+
// BUILD_VECTOR requires all inputs to be of the same type, find the
// maximum type and extend them all.
EVT SVT = VT.getScalarType();
OpenPOWER on IntegriCloud