summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
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
commit42d262f410357a906d5191027384d9181733c461 (patch)
tree28e6775ccd001ecc55830f6b0aa3c75434c74318 /llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
parentf80d68847dcf2a5923eb1e7acfc50c290fdc8f79 (diff)
downloadbcm5719-llvm-42d262f410357a906d5191027384d9181733c461.tar.gz
bcm5719-llvm-42d262f410357a906d5191027384d9181733c461.zip
Allow SelectionDAG::FoldConstantArithmetic to work when it's called with a vector VT but scalar values.
llvm-svn: 207835
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index bf311226cd9..7058c4e95ae 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/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);
}
OpenPOWER on IntegriCloud