@@ -699,8 +699,7 @@ static void legalizeAndOptimizeInductions(VPlan &Plan) {
699699 continue ;
700700
701701 const InductionDescriptor &ID = PtrIV->getInductionDescriptor ();
702- VPValue *StartV =
703- Plan.getOrAddLiveIn (ConstantInt::get (ID.getStep ()->getType (), 0 ));
702+ VPValue *StartV = Plan.getConstantInt (ID.getStep ()->getType (), 0 );
704703 VPValue *StepV = PtrIV->getOperand (1 );
705704 VPScalarIVStepsRecipe *Steps = createScalarIVSteps (
706705 Plan, InductionDescriptor::IK_IntInduction, Instruction::Add, nullptr ,
@@ -836,7 +835,7 @@ static VPValue *optimizeEarlyExitInductionUser(VPlan &Plan,
836835 // changed it means the exit is using the incremented value, so we need to
837836 // add the step.
838837 if (Incoming != WideIV) {
839- VPValue *One = Plan.getOrAddLiveIn ( ConstantInt::get ( CanonicalIVType, 1 ) );
838+ VPValue *One = Plan.getConstantInt ( CanonicalIVType, 1 );
840839 EndValue = B.createNaryOp (Instruction::Add, {EndValue, One}, DL);
841840 }
842841
@@ -882,7 +881,7 @@ static VPValue *optimizeLatchExitInductionUser(
882881 return B.createNaryOp (Instruction::Sub, {EndValue, Step}, {}, " ind.escape" );
883882 if (ScalarTy->isPointerTy ()) {
884883 Type *StepTy = TypeInfo.inferScalarType (Step);
885- auto *Zero = Plan.getOrAddLiveIn ( ConstantInt::get ( StepTy, 0 ) );
884+ auto *Zero = Plan.getConstantInt ( StepTy, 0 );
886885 return B.createPtrAdd (EndValue,
887886 B.createNaryOp (Instruction::Sub, {Zero, Step}),
888887 DebugLoc::getUnknown (), " ind.escape" );
@@ -1574,9 +1573,9 @@ static bool optimizeVectorInductionWidthForTCAndVFUF(VPlan &Plan,
15741573 continue ;
15751574
15761575 // Update IV operands and comparison bound to use new narrower type.
1577- auto *NewStart = Plan.getOrAddLiveIn ( ConstantInt::get ( NewIVTy, 0 ) );
1576+ auto *NewStart = Plan.getConstantInt ( NewIVTy, 0 );
15781577 WideIV->setStartValue (NewStart);
1579- auto *NewStep = Plan.getOrAddLiveIn ( ConstantInt::get ( NewIVTy, 1 ) );
1578+ auto *NewStep = Plan.getConstantInt ( NewIVTy, 1 );
15801579 WideIV->setStepValue (NewStep);
15811580
15821581 auto *NewBTC = new VPWidenCastRecipe (
@@ -1695,8 +1694,7 @@ static bool tryToReplaceALMWithWideALM(VPlan &Plan, ElementCount VF,
16951694
16961695 // When using wide lane masks, the return type of the get.active.lane.mask
16971696 // intrinsic is VF x UF (last operand).
1698- VPValue *ALMMultiplier =
1699- Plan.getOrAddLiveIn (ConstantInt::get (IntegerType::getInt64Ty (Ctx), UF));
1697+ VPValue *ALMMultiplier = Plan.getConstantInt (64 , UF);
17001698 EntryALM->setOperand (2 , ALMMultiplier);
17011699 LoopALM->setOperand (2 , ALMMultiplier);
17021700
@@ -2403,7 +2401,7 @@ static VPActiveLaneMaskPHIRecipe *addVPLaneMaskPhiAndUpdateExitBranch(
24032401
24042402 // Create the active lane mask instruction in the VPlan preheader.
24052403 VPValue *ALMMultiplier =
2406- Plan.getOrAddLiveIn ( ConstantInt::get ( TopRegion->getCanonicalIVType (), 1 ) );
2404+ Plan.getConstantInt ( TopRegion->getCanonicalIVType (), 1 );
24072405 auto *EntryALM = Builder.createNaryOp (VPInstruction::ActiveLaneMask,
24082406 {EntryIncrement, TC, ALMMultiplier}, DL,
24092407 " active.lane.mask.entry" );
@@ -2790,8 +2788,7 @@ void VPlanTransforms::addExplicitVectorLength(
27902788
27912789 if (MaxSafeElements) {
27922790 // Support for MaxSafeDist for correct loop emission.
2793- VPValue *AVLSafe =
2794- Plan.getOrAddLiveIn (ConstantInt::get (CanIVTy, *MaxSafeElements));
2791+ VPValue *AVLSafe = Plan.getConstantInt (CanIVTy, *MaxSafeElements);
27952792 VPValue *Cmp = Builder.createICmp (ICmpInst::ICMP_ULT, AVL, AVLSafe);
27962793 AVL = Builder.createSelect (Cmp, AVL, AVLSafe, DebugLoc::getUnknown (),
27972794 " safe_avl" );
@@ -2904,9 +2901,8 @@ void VPlanTransforms::canonicalizeEVLLoops(VPlan &Plan) {
29042901
29052902 Type *AVLTy = VPTypeAnalysis (Plan).inferScalarType (AVLNext);
29062903 VPBuilder Builder (LatchExitingBr);
2907- VPValue *Cmp =
2908- Builder.createICmp (CmpInst::ICMP_EQ, AVLNext,
2909- Plan.getOrAddLiveIn (ConstantInt::getNullValue (AVLTy)));
2904+ VPValue *Cmp = Builder.createICmp (CmpInst::ICMP_EQ, AVLNext,
2905+ Plan.getConstantInt (AVLTy, 0 ));
29102906 Builder.createNaryOp (VPInstruction::BranchOnCond, Cmp);
29112907 LatchExitingBr->eraseFromParent ();
29122908}
@@ -2930,8 +2926,7 @@ void VPlanTransforms::replaceSymbolicStrides(
29302926 // Only handle constant strides for now.
29312927 continue ;
29322928
2933- auto *CI =
2934- Plan.getOrAddLiveIn (ConstantInt::get (Stride->getType (), *StrideConst));
2929+ auto *CI = Plan.getConstantInt (*StrideConst);
29352930 if (VPValue *StrideVPV = Plan.getLiveIn (StrideV))
29362931 StrideVPV->replaceUsesWithIf (CI, CanUseVersionedStride);
29372932
@@ -2946,7 +2941,7 @@ void VPlanTransforms::replaceSymbolicStrides(
29462941 unsigned BW = U->getType ()->getScalarSizeInBits ();
29472942 APInt C =
29482943 isa<SExtInst>(U) ? StrideConst->sext (BW) : StrideConst->zext (BW);
2949- VPValue *CI = Plan.getOrAddLiveIn ( ConstantInt::get (U-> getType (), C) );
2944+ VPValue *CI = Plan.getConstantInt (C );
29502945 StrideVPV->replaceUsesWithIf (CI, CanUseVersionedStride);
29512946 }
29522947 RewriteMap[StrideV] = PSE.getSCEV (StrideV);
@@ -3125,8 +3120,7 @@ void VPlanTransforms::createInterleaveGroups(
31253120 DL.getTypeAllocSize (getLoadStoreType (IRInsertPos)) *
31263121 IG->getIndex (IRInsertPos),
31273122 /* IsSigned=*/ true );
3128- VPValue *OffsetVPV =
3129- Plan.getOrAddLiveIn (ConstantInt::get (Plan.getContext (), -Offset));
3123+ VPValue *OffsetVPV = Plan.getConstantInt (-Offset);
31303124 VPBuilder B (InsertPos);
31313125 Addr = B.createNoWrapPtrAdd (InsertPos->getAddr (), OffsetVPV, NW);
31323126 }
@@ -3867,8 +3861,7 @@ void VPlanTransforms::materializeBackedgeTakenCount(VPlan &Plan,
38673861 VPBuilder Builder (VectorPH, VectorPH->begin ());
38683862 auto *TCTy = VPTypeAnalysis (Plan).inferScalarType (Plan.getTripCount ());
38693863 auto *TCMO = Builder.createNaryOp (
3870- Instruction::Sub,
3871- {Plan.getTripCount (), Plan.getOrAddLiveIn (ConstantInt::get (TCTy, 1 ))},
3864+ Instruction::Sub, {Plan.getTripCount (), Plan.getConstantInt (TCTy, 1 )},
38723865 DebugLoc::getCompilerGenerated (), " trip.count.minus.1" );
38733866 BTC->replaceAllUsesWith (TCMO);
38743867}
@@ -3993,9 +3986,8 @@ void VPlanTransforms::materializeVectorTripCount(VPlan &Plan,
39933986 if (TailByMasking) {
39943987 TC = Builder.createNaryOp (
39953988 Instruction::Add,
3996- {TC, Builder.createNaryOp (
3997- Instruction::Sub,
3998- {Step, Plan.getOrAddLiveIn (ConstantInt::get (TCTy, 1 ))})},
3989+ {TC, Builder.createNaryOp (Instruction::Sub,
3990+ {Step, Plan.getConstantInt (TCTy, 1 )})},
39993991 DebugLoc::getCompilerGenerated (), " n.rnd.up" );
40003992 }
40013993
@@ -4017,8 +4009,8 @@ void VPlanTransforms::materializeVectorTripCount(VPlan &Plan,
40174009 if (RequiresScalarEpilogue) {
40184010 assert (!TailByMasking &&
40194011 " requiring scalar epilogue is not supported with fail folding" );
4020- VPValue *IsZero = Builder. createICmp (
4021- CmpInst::ICMP_EQ, R, Plan.getOrAddLiveIn ( ConstantInt::get ( TCTy, 0 ) ));
4012+ VPValue *IsZero =
4013+ Builder. createICmp ( CmpInst::ICMP_EQ, R, Plan.getConstantInt ( TCTy, 0 ));
40224014 R = Builder.createSelect (IsZero, Step, R);
40234015 }
40244016
@@ -4056,7 +4048,7 @@ void VPlanTransforms::materializeVFAndVFxUF(VPlan &Plan, VPBasicBlock *VectorPH,
40564048 }
40574049 VF.replaceAllUsesWith (RuntimeVF);
40584050
4059- VPValue *UF = Plan.getOrAddLiveIn ( ConstantInt::get ( TCTy, Plan.getUF () ));
4051+ VPValue *UF = Plan.getConstantInt ( TCTy, Plan.getUF ());
40604052 VPValue *MulByUF = Builder.createNaryOp (Instruction::Mul, {RuntimeVF, UF});
40614053 VFxUF.replaceAllUsesWith (MulByUF);
40624054}
@@ -4346,7 +4338,7 @@ void VPlanTransforms::narrowInterleaveGroups(VPlan &Plan, ElementCount VF,
43464338 } else {
43474339 Inc->setOperand (1 , UF);
43484340 Plan.getVF ().replaceAllUsesWith (
4349- Plan.getOrAddLiveIn ( ConstantInt::get ( CanIV->getScalarType (), 1 ) ));
4341+ Plan.getConstantInt ( CanIV->getScalarType (), 1 ));
43504342 }
43514343 removeDeadRecipes (Plan);
43524344}
0 commit comments