From f8e11b803d708bbe78407cfac4fab5b56044c5da Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Thu, 28 Sep 2017 06:17:19 +0000 Subject: [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 --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp') 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); -- cgit v1.2.3