diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-01-26 15:50:20 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-01-26 15:50:20 +0000 |
commit | f531cf8964c2d0e49a35bf4f05478b498b2a5fd4 (patch) | |
tree | b45f0b4505402241f8c3dae4c51aa55954c9bd30 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | 0b4eb1ead18e437b3f630bf3f4c082adab417170 (diff) | |
download | bcm5719-llvm-f531cf8964c2d0e49a35bf4f05478b498b2a5fd4.tar.gz bcm5719-llvm-f531cf8964c2d0e49a35bf4f05478b498b2a5fd4.zip |
[DAGCombine] reduceBuildVecToShuffle - ensure EXTRACT_VECTOR_ELT index is in range
From OSS Fuzz Test Case #5688
llvm-svn: 323535
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index d353dc241d1..73b86632bc4 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -14779,12 +14779,16 @@ SDValue DAGCombiner::reduceBuildVecToShuffle(SDNode *N) { } // Not an undef or zero. If the input is something other than an - // EXTRACT_VECTOR_ELT with a constant index, bail out. + // EXTRACT_VECTOR_ELT with an in-range constant index, bail out. if (Op.getOpcode() != ISD::EXTRACT_VECTOR_ELT || !isa<ConstantSDNode>(Op.getOperand(1))) return SDValue(); SDValue ExtractedFromVec = Op.getOperand(0); + APInt ExtractIdx = cast<ConstantSDNode>(Op.getOperand(1))->getAPIntValue(); + if (ExtractIdx.uge(ExtractedFromVec.getValueType().getVectorNumElements())) + return SDValue(); + // All inputs must have the same element type as the output. if (VT.getVectorElementType() != ExtractedFromVec.getValueType().getVectorElementType()) |