From c6bb0e2a511dcb0adc57821f79b83fe00d3fb4da Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Tue, 18 Aug 2015 22:07:25 +0000 Subject: [InstSimplify] Don't assume getAggregateElement will succeed It isn't always possible to get a value from getAggregateElement. This fixes PR24488. llvm-svn: 245365 --- llvm/lib/Analysis/VectorUtils.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'llvm/lib/Analysis/VectorUtils.cpp') diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp index 9a0af3b..7214095 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; -- cgit v1.1