summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2014-05-02 12:35:22 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2014-05-02 12:35:22 +0000
commitbcf15018398f0c9303d66f4dabdfdd9006555170 (patch)
tree45215b64ae38490b866b555d8878e4184fce220d /lib
parent74e9519ef9ff97f1d9f74085a4ba515dff354cd1 (diff)
downloadllvm-bcf15018398f0c9303d66f4dabdfdd9006555170.tar.gz
llvm-bcf15018398f0c9303d66f4dabdfdd9006555170.tar.bz2
llvm-bcf15018398f0c9303d66f4dabdfdd9006555170.tar.xz
Allow SelectionDAG::FoldConstantArithmetic to work when it's called with a vector VT but scalar values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207835 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index bf311226cd..7058c4e95a 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -2924,11 +2924,17 @@ SDValue SelectionDAG::FoldConstantArithmetic(unsigned Opcode, EVT VT,
}
}
+ assert((Scalar1 && Scalar2) ||
+ VT.getVectorNumElements() == Outputs.size() && "No scalar or vector!");
+
// Handle the scalar case first.
- if (Scalar1 && Scalar2)
+ if (!VT.isVector())
return Outputs.back();
- // Otherwise build a big vector out of the scalar elements we generated.
+ // We may have a vector type but a scalar result. Create a splat.
+ Outputs.resize(VT.getVectorNumElements(), Outputs.back());
+
+ // Build a big vector out of the scalar elements we generated.
return getNode(ISD::BUILD_VECTOR, SDLoc(), VT, Outputs);
}