1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

[X86][SSE] LowerINSERT_VECTOR_ELT - early out for out of range indices

Fixes OSS-Fuzz #15662

llvm-svn: 365180
This commit is contained in:
Simon Pilgrim 2019-07-05 10:34:53 +00:00
parent 1676daeb17
commit a505ee9998
2 changed files with 27 additions and 4 deletions

View File

@ -17091,10 +17091,10 @@ SDValue X86TargetLowering::LowerINSERT_VECTOR_ELT(SDValue Op,
SDValue N0 = Op.getOperand(0);
SDValue N1 = Op.getOperand(1);
SDValue N2 = Op.getOperand(2);
if (!isa<ConstantSDNode>(N2))
auto *N2C = dyn_cast<ConstantSDNode>(N2);
if (!N2C || N2C->getAPIntValue().uge(NumElts))
return SDValue();
auto *N2C = cast<ConstantSDNode>(N2);
assert(N2C->getAPIntValue().ult(NumElts) && "Out of range element index");
uint64_t IdxVal = N2C->getZExtValue();
bool IsZeroElt = X86::isZeroNode(N1);

View File

@ -100,5 +100,28 @@ entry:
%tmp3 = fadd double %tmp2, %A
ret double %tmp3
}
declare <2 x double> @foo()
; OSS-Fuzz #15662
; https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=15662
define <4 x i32> @ossfuzz15662(<4 x i32*>* %in) {
; X32-LABEL: ossfuzz15662:
; X32: # %bb.0:
; X32-NEXT: xorps %xmm0, %xmm0
; X32-NEXT: movaps %xmm0, (%eax)
; X32-NEXT: xorps %xmm0, %xmm0
; X32-NEXT: retl
;
; X64-LABEL: ossfuzz15662:
; X64: # %bb.0:
; X64-NEXT: xorps %xmm0, %xmm0
; X64-NEXT: movaps %xmm0, (%rax)
; X64-NEXT: xorps %xmm0, %xmm0
; X64-NEXT: retq
%C10 = icmp ule i1 false, false
%C3 = icmp ule i1 true, undef
%B = sdiv i1 %C10, %C3
%I = insertelement <4 x i32> zeroinitializer, i32 0, i1 %B
store <4 x i32> %I, <4 x i32>* undef
ret <4 x i32> zeroinitializer
}