summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorGeorge Burgess IV <george.burgess.iv@gmail.com>2017-09-28 06:17:19 +0000
committerGeorge Burgess IV <george.burgess.iv@gmail.com>2017-09-28 06:17:19 +0000
commitf8e11b803d708bbe78407cfac4fab5b56044c5da (patch)
treebdb0cf2bf80e4a059fefe8b4569174ae4e3685cf /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parent2e9cd5693fb47ba0c8a2e6b6a0d3296bebbb1cec (diff)
downloadbcm5719-llvm-f8e11b803d708bbe78407cfac4fab5b56044c5da.tar.gz
bcm5719-llvm-f8e11b803d708bbe78407cfac4fab5b56044c5da.zip
[DAGCombiner] Fix an off-by-one error in vector logic
Without this, we could end up trying to get the Nth (0-indexed) element from a subvector of size N. Differential Revision: https://reviews.llvm.org/D37880 llvm-svn: 314380
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index c171d76e2ce..35d7ccb78c4 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -14501,8 +14501,8 @@ SDValue DAGCombiner::reduceBuildVecToShuffle(SDNode *N) {
}
NearestPow2 = PowerOf2Ceil(MaxIndex);
- if (InVT.isSimple() && (NearestPow2 > 2) &&
- ((NumElems * 2) < NearestPow2)) {
+ if (InVT.isSimple() && NearestPow2 > 2 && MaxIndex < NearestPow2 &&
+ NumElems * 2 < NearestPow2) {
unsigned SplitSize = NearestPow2 / 2;
EVT SplitVT = EVT::getVectorVT(*DAG.getContext(),
InVT.getVectorElementType(), SplitSize);
OpenPOWER on IntegriCloud