diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/Analysis/VectorUtils.cpp | 8 |
2 files changed, 4 insertions, 9 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index f9d4524f012..db8639613fb 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -3578,11 +3578,6 @@ static Value *SimplifyExtractElementInst(Value *Vec, Value *Idx, const Query &, unsigned IndexVal = IdxC->getZExtValue(); unsigned VectorWidth = Vec->getType()->getVectorNumElements(); - // If this is extracting an invalid index, turn this into undef, to avoid - // crashing the code below. - if (IndexVal >= VectorWidth) - return UndefValue::get(Vec->getType()->getVectorElementType()); - if (Value *Elt = findScalarElement(Vec, IndexVal)) return Elt; } diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp index 9a0af3bd8be..72140952ecb 100644 --- a/llvm/lib/Analysis/VectorUtils.cpp +++ b/llvm/lib/Analysis/VectorUtils.cpp @@ -398,10 +398,10 @@ Value *llvm::findScalarElement(Value *V, unsigned EltNo) { // Extract a value from a vector add operation with a constant zero. Value *Val = nullptr; Constant *Con = nullptr; - if (match(V, m_Add(m_Value(Val), m_Constant(Con)))) { - if (Con->getAggregateElement(EltNo)->isNullValue()) - return findScalarElement(Val, EltNo); - } + if (match(V, m_Add(m_Value(Val), m_Constant(Con)))) + if (Constant *Elt = Con->getAggregateElement(EltNo)) + if (Elt->isNullValue()) + return findScalarElement(Val, EltNo); // Otherwise, we don't know. return nullptr; |