llvm.org GIT mirror llvm / db44ab7
Merging r245365 and r245369: ------------------------------------------------------------------------ r245365 | majnemer | 2015-08-18 15:07:25 -0700 (Tue, 18 Aug 2015) | 4 lines [InstSimplify] Don't assume getAggregateElement will succeed It isn't always possible to get a value from getAggregateElement. This fixes PR24488. ------------------------------------------------------------------------ ------------------------------------------------------------------------ r245369 | majnemer | 2015-08-18 15:18:22 -0700 (Tue, 18 Aug 2015) | 3 lines [InstSimplify] Remove unused variable No functionality change is intended. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_37@245572 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 4 years ago
3 changed file(s) with 15 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
35733573
35743574 // If extracting a specified index from the vector, see if we can recursively
35753575 // find a previously computed scalar that was inserted into the vector.
3576 if (auto *IdxC = dyn_cast(Idx)) {
3577 unsigned IndexVal = IdxC->getZExtValue();
3578 unsigned VectorWidth = Vec->getType()->getVectorNumElements();
3579
3580 // If this is extracting an invalid index, turn this into undef, to avoid
3581 // crashing the code below.
3582 if (IndexVal >= VectorWidth)
3583 return UndefValue::get(Vec->getType()->getVectorElementType());
3584
3585 if (Value *Elt = findScalarElement(Vec, IndexVal))
3576 if (auto *IdxC = dyn_cast(Idx))
3577 if (Value *Elt = findScalarElement(Vec, IdxC->getZExtValue()))
35863578 return Elt;
3587 }
35883579
35893580 return nullptr;
35903581 }
401401 if (match(V,
402402 llvm::PatternMatch::m_Add(llvm::PatternMatch::m_Value(Val),
403403 llvm::PatternMatch::m_Constant(Con)))) {
404 if (Con->getAggregateElement(EltNo)->isNullValue())
405 return findScalarElement(Val, EltNo);
404 if (Constant *Elt = Con->getAggregateElement(EltNo))
405 if (Elt->isNullValue())
406 return findScalarElement(Val, EltNo);
406407 }
407408
408409 // Otherwise, we don't know.
3535 ; CHECK-LABEL: @test3(
3636 ; CHECK: ret i32 %a
3737 }
38
39 define i8 @test4(<8 x i8> %V) {
40 %add = add <8 x i8> %V, bitcast (double 0x319BEB8FD172E36 to <8 x i8>)
41 %extract = extractelement <8 x i8> %add, i32 6
42 ret i8 %extract
43 ; CHECK-LABEL: @test4(
44 ; CHECK: %[[add:.*]] = add <8 x i8> %V, bitcast (<1 x double> to <8 x i8>)
45 ; CHECK-NEXT: %[[extract:.*]] = extractelement <8 x i8> %[[add]], i32 6
46 ; CHECK-NEXT: ret i8 %[[extract]]
47 }