From f91a07274585be0d46bd79ec1a95deeaf966cae5 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Sat, 20 Jan 2018 17:16:01 +0000 Subject: [PATCH] [X86][SSE] Check for out of bounds PEXTR/PINSR indices during faux shuffle combining. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323045 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86ISelLowering.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index f4049bf9de4f..0a2db3450e57 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -6014,8 +6014,11 @@ static bool getFauxShuffleMask(SDValue N, SmallVectorImpl &Mask, case X86ISD::PINSRW: { SDValue InVec = N.getOperand(0); SDValue InScl = N.getOperand(1); + SDValue InIndex = N.getOperand(2); + if (!isa(InIndex) || + cast(InIndex)->getAPIntValue().uge(NumElts)) + return false; uint64_t InIdx = N.getConstantOperandVal(2); - assert(InIdx < NumElts && "Illegal insertion index"); // Attempt to recognise a PINSR*(VEC, 0, Idx) shuffle pattern. if (X86::isZeroNode(InScl)) { @@ -6033,8 +6036,12 @@ static bool getFauxShuffleMask(SDValue N, SmallVectorImpl &Mask, return false; SDValue ExVec = InScl.getOperand(0); + SDValue ExIndex = InScl.getOperand(1); + if (!isa(ExIndex) || + cast(ExIndex)->getAPIntValue().uge(NumElts)) + return false; uint64_t ExIdx = InScl.getConstantOperandVal(1); - assert(ExIdx < NumElts && "Illegal extraction index"); + Ops.push_back(InVec); Ops.push_back(ExVec); for (unsigned i = 0; i != NumElts; ++i)