mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 19:52:54 +01:00
[InstSimplify] Check for in range extraction index before calling APInt::getZExtValue()
Reduced from oss-fuzz #4768 test case llvm-svn: 321454
This commit is contained in:
parent
8032e9b258
commit
345940ba6e
@ -3897,8 +3897,9 @@ static Value *SimplifyExtractElementInst(Value *Vec, Value *Idx, const SimplifyQ
|
||||
// If extracting a specified index from the vector, see if we can recursively
|
||||
// find a previously computed scalar that was inserted into the vector.
|
||||
if (auto *IdxC = dyn_cast<ConstantInt>(Idx))
|
||||
if (Value *Elt = findScalarElement(Vec, IdxC->getZExtValue()))
|
||||
return Elt;
|
||||
if (IdxC->getValue().ule(Vec->getType()->getVectorNumElements()))
|
||||
if (Value *Elt = findScalarElement(Vec, IdxC->getZExtValue()))
|
||||
return Elt;
|
||||
|
||||
// An undef extract index can be arbitrarily chosen to be an out-of-range
|
||||
// index value, which would result in the instruction being undef.
|
||||
|
13
test/Transforms/InstSimplify/extract-element.ll
Normal file
13
test/Transforms/InstSimplify/extract-element.ll
Normal file
@ -0,0 +1,13 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
|
||||
; Weird Types
|
||||
|
||||
define i129 @vec_extract_negidx(<3 x i129> %a) {
|
||||
; CHECK-LABEL: @vec_extract_negidx(
|
||||
; CHECK-NEXT: [[E1:%.*]] = extractelement <3 x i129> [[A:%.*]], i129 -1
|
||||
; CHECK-NEXT: ret i129 [[E1]]
|
||||
;
|
||||
%E1 = extractelement <3 x i129> %a, i129 -1
|
||||
ret i129 %E1
|
||||
}
|
Loading…
Reference in New Issue
Block a user