[X86][SSE] combineExtractVectorElt - add early-out to return zero/undef for out-of-range extraction indices.

llvm-svn: 359406
This commit is contained in:
Simon Pilgrim 2019-04-28 19:12:58 +00:00
parent a1f420de8c
commit d5cc753b6d
1 changed files with 4 additions and 2 deletions

View File

@ -34838,9 +34838,11 @@ static SDValue combineExtractVectorElt(SDNode *N, SelectionDAG &DAG,
SDLoc dl(InputVector);
bool IsPextr = N->getOpcode() != ISD::EXTRACT_VECTOR_ELT;
if (CIdx && CIdx->getAPIntValue().uge(SrcVT.getVectorNumElements()))
return IsPextr ? DAG.getConstant(0, dl, VT) : DAG.getUNDEF(VT);
// Integer Constant Folding.
if (VT.isInteger() && CIdx &&
CIdx->getAPIntValue().ult(SrcVT.getVectorNumElements())) {
if (CIdx && VT.isInteger()) {
APInt UndefVecElts;
SmallVector<APInt, 16> EltBits;
unsigned VecEltBitWidth = SrcVT.getScalarSizeInBits();