@@ -419,7 +419,6 @@ Instruction *InstCombinerImpl::visitExtractElementInst(ExtractElementInst &EI) {
419419 // If extracting a specified index from the vector, see if we can recursively
420420 // find a previously computed scalar that was inserted into the vector.
421421 auto *IndexC = dyn_cast<ConstantInt>(Index);
422- auto *II = dyn_cast<IntrinsicInst>(SrcVec);
423422 bool HasKnownValidIndex = false ;
424423 if (IndexC) {
425424 // Canonicalize type of constant indices to i64 to simplify CSE
@@ -430,7 +429,7 @@ Instruction *InstCombinerImpl::visitExtractElementInst(ExtractElementInst &EI) {
430429 unsigned NumElts = EC.getKnownMinValue ();
431430 HasKnownValidIndex = IndexC->getValue ().ult (NumElts);
432431
433- if (II ) {
432+ if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(SrcVec) ) {
434433 Intrinsic::ID IID = II->getIntrinsicID ();
435434 // Index needs to be lower than the minimum size of the vector, because
436435 // for scalable vector, the vector size is known at run time.
@@ -465,9 +464,10 @@ Instruction *InstCombinerImpl::visitExtractElementInst(ExtractElementInst &EI) {
465464
466465 // If SrcVec is a subvector starting at index 0, extract from the
467466 // wider source vector
468- if (II && II->getIntrinsicID () == Intrinsic::vector_extract)
469- if (cast<ConstantInt>(II->getArgOperand (1 ))->isZero ())
470- return ExtractElementInst::Create (II->getArgOperand (0 ), Index);
467+ Value *V;
468+ if (match (SrcVec,
469+ m_Intrinsic<Intrinsic::vector_extract>(m_Value (V), m_Zero ())))
470+ return ExtractElementInst::Create (V, Index);
471471
472472 // TODO come up with a n-ary matcher that subsumes both unary and
473473 // binary matchers.
0 commit comments