diff options
author | Amara Emerson <aemerson@apple.com> | 2018-09-13 21:28:58 +0000 |
---|---|---|
committer | Amara Emerson <aemerson@apple.com> | 2018-09-13 21:28:58 +0000 |
commit | ef600cbd86db579f1dc490b2cb65808d6ff7067f (patch) | |
tree | 3d546af8441fc4f30ca3f7176748006b086a3ddd /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | b6d188da085a9cee7dfd18889407c068116f4d99 (diff) | |
download | bcm5719-llvm-ef600cbd86db579f1dc490b2cb65808d6ff7067f.tar.gz bcm5719-llvm-ef600cbd86db579f1dc490b2cb65808d6ff7067f.zip |
[DAGCombine] Fix crash when store merging created an extract_subvector with invalid index.
Differential Revision: https://reviews.llvm.org/D51831
llvm-svn: 342183
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 20e749ba569..71048b14683 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -13843,17 +13843,24 @@ bool DAGCombiner::MergeStoresOfConstantsOrVecElts( Val.getOpcode() == ISD::EXTRACT_SUBVECTOR)) { SDValue Vec = Val.getOperand(0); EVT MemVTScalarTy = MemVT.getScalarType(); + SDValue Idx = Val.getOperand(1); // We may need to add a bitcast here to get types to line up. if (MemVTScalarTy != Vec.getValueType()) { unsigned Elts = Vec.getValueType().getSizeInBits() / MemVTScalarTy.getSizeInBits(); + if (Val.getValueType().isVector()) { + unsigned IdxC = cast<ConstantSDNode>(Idx)->getZExtValue(); + unsigned NewIdx = + ((uint64_t)IdxC * MemVT.getVectorNumElements()) / Elts; + Idx = DAG.getConstant(NewIdx, SDLoc(Val), Idx.getValueType()); + } EVT NewVecTy = EVT::getVectorVT(*DAG.getContext(), MemVTScalarTy, Elts); Vec = DAG.getBitcast(NewVecTy, Vec); } auto OpC = (MemVT.isVector()) ? ISD::EXTRACT_SUBVECTOR : ISD::EXTRACT_VECTOR_ELT; - Val = DAG.getNode(OpC, SDLoc(Val), MemVT, Vec, Val.getOperand(1)); + Val = DAG.getNode(OpC, SDLoc(Val), MemVT, Vec, Idx); } Ops.push_back(Val); } |