summaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff options
context:
space:
mode:
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2014-03-22 01:47:22 +0000
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2014-03-22 01:47:22 +0000
commitd47cb57ab88956197c266df3353347eb31790781 (patch)
treeb09d18ac4d85405c17bbc2ab48eede93f230124a /lib/CodeGen/SelectionDAG/SelectionDAG.cpp
parent4696def45d683f1b1ebed8d85688f4c31fce6258 (diff)
downloadllvm-d47cb57ab88956197c266df3353347eb31790781.tar.gz
llvm-d47cb57ab88956197c266df3353347eb31790781.tar.bz2
llvm-d47cb57ab88956197c266df3353347eb31790781.tar.xz
[DAG] Fix an assertion failure caused by an invalid cast in method 'BuildVectorSDNode::isConstantSplat'
This patch renames method 'isConstantSplat' as 'getConstantSplatValue' (mainly for consistency reasons), and rewrites its logic to ensure that we always perform a legal 'cast<ConstantSDNode>'. Added test shift-combine-crash.ll to verify that DAGCombiner no longer crashes with an assertion failure in the attempt to simplify a vector shift by a vector of all undef counts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204536 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index df8d423ab2..029011cffc 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -6573,15 +6573,14 @@ bool BuildVectorSDNode::isConstantSplat(APInt &SplatValue,
return true;
}
-ConstantSDNode *BuildVectorSDNode::isConstantSplat() const {
+ConstantSDNode *BuildVectorSDNode::getConstantSplatValue() const {
SDValue Op0 = getOperand(0);
- for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
- SDValue Opi = getOperand(i);
- unsigned Opc = Opi.getOpcode();
- if ((Opc != ISD::UNDEF && Opc != ISD::Constant && Opc != ISD::ConstantFP) ||
- Opi != Op0)
+ if (Op0.getOpcode() != ISD::Constant)
+ return nullptr;
+
+ for (unsigned i = 1, e = getNumOperands(); i != e; ++i)
+ if (getOperand(i) != Op0)
return nullptr;
- }
return cast<ConstantSDNode>(Op0);
}