@@ -470,10 +470,8 @@ static VPValue *
470470cloneForLane (VPlan &Plan, VPBuilder &Builder, Type *IdxTy,
471471 VPRecipeWithIRFlags *DefR, VPLane Lane,
472472 const DenseMap<VPValue *, SmallVector<VPValue *>> &Def2LaneDefs) {
473-
474473 VPValue *Op;
475- if (match (DefR,
476- m_VPInstruction<VPInstruction::UnpackVector>(m_VPValue (Op)))) {
474+ if (match (DefR, m_VPInstruction<VPInstruction::Unpack>(m_VPValue (Op)))) {
477475 auto LaneDefs = Def2LaneDefs.find (Op);
478476 if (LaneDefs != Def2LaneDefs.end ())
479477 return LaneDefs->second [Lane.getKnownLane ()];
@@ -486,20 +484,22 @@ cloneForLane(VPlan &Plan, VPBuilder &Builder, Type *IdxTy,
486484 // Collect the operands at Lane, creating extracts as needed.
487485 SmallVector<VPValue *> NewOps;
488486 for (VPValue *Op : DefR->operands ()) {
489- if (Lane.getKind () == VPLane::Kind::ScalableLast) {
490- match (Op, m_VPInstruction<VPInstruction::UnpackVector>(m_VPValue (Op)));
491- NewOps.push_back (
492- Builder.createNaryOp (VPInstruction::ExtractLastElement, {Op}));
493- continue ;
494- }
495-
496487 // If Op is a definition that has been unrolled, directly use the clone for
497488 // the corresponding lane.
498489 auto LaneDefs = Def2LaneDefs.find (Op);
499490 if (LaneDefs != Def2LaneDefs.end ()) {
500491 NewOps.push_back (LaneDefs->second [Lane.getKnownLane ()]);
501492 continue ;
502493 }
494+ if (Lane.getKind () == VPLane::Kind::ScalableLast) {
495+ // Look through mandatory Unpack.
496+ [[maybe_unused]] bool Matched =
497+ match (Op, m_VPInstruction<VPInstruction::Unpack>(m_VPValue (Op)));
498+ assert (Matched && " original op must have been Unpack" );
499+ NewOps.push_back (
500+ Builder.createNaryOp (VPInstruction::ExtractLastElement, {Op}));
501+ continue ;
502+ }
503503 if (vputils::isSingleScalar (Op)) {
504504 NewOps.push_back (Op);
505505 continue ;
@@ -513,8 +513,8 @@ cloneForLane(VPlan &Plan, VPBuilder &Builder, Type *IdxTy,
513513 }
514514 VPValue *Idx =
515515 Plan.getOrAddLiveIn (ConstantInt::get (IdxTy, Lane.getKnownLane ()));
516- NewOps. push_back (
517- Builder. createNaryOp (Instruction::ExtractElement, {Op, Idx}) );
516+ VPValue *Ext = Builder. createNaryOp (Instruction::ExtractElement, {Op, Idx});
517+ NewOps. push_back (Ext );
518518 }
519519
520520 VPRecipeWithIRFlags *New;
@@ -564,7 +564,7 @@ void VPlanTransforms::replicateByVF(VPlan &Plan, ElementCount VF) {
564564 cast<VPReplicateRecipe>(&R)->isSingleScalar ()) ||
565565 (isa<VPInstruction>(&R) &&
566566 !cast<VPInstruction>(&R)->doesGeneratePerAllLanes () &&
567- cast<VPInstruction>(&R)->getOpcode () != VPInstruction::UnpackVector ))
567+ cast<VPInstruction>(&R)->getOpcode () != VPInstruction::Unpack ))
568568 continue ;
569569
570570 auto *DefR = cast<VPRecipeWithIRFlags>(&R);
0 commit comments