@@ -3283,8 +3283,10 @@ void VPlanTransforms::materializeVectorTripCount(VPlan &Plan,
32833283 bool TailByMasking,
32843284 bool RequiresScalarEpilogue) {
32853285 VPValue &VectorTC = Plan.getVectorTripCount ();
3286- if (VectorTC.getNumUsers () == 0 ||
3287- (VectorTC.isLiveIn () && VectorTC.getLiveInIRValue ()))
3286+ assert (VectorTC.isLiveIn () && " vector-trip-count must be a live-in" );
3287+ // There's nothing to do if there are no users of the vector trip count or its
3288+ // IR value has already been set.
3289+ if (VectorTC.getNumUsers () == 0 || VectorTC.getLiveInIRValue ())
32883290 return ;
32893291 VPValue *TC = Plan.getTripCount ();
32903292 Type *TCTy = VPTypeAnalysis (Plan).inferScalarType (TC);
@@ -3306,16 +3308,17 @@ void VPlanTransforms::materializeVectorTripCount(VPlan &Plan,
33063308 {TC, Builder.createNaryOp (
33073309 Instruction::Sub,
33083310 {Step, Plan.getOrAddLiveIn (ConstantInt::get (TCTy, 1 ))})},
3309- DebugLoc::getUnknown (), " n.rnd.up" );
3311+ DebugLoc::getCompilerGenerated (), " n.rnd.up" );
33103312 }
33113313
33123314 // Now we need to generate the expression for the part of the loop that the
33133315 // vectorized body will execute. This is equal to N - (N % Step) if scalar
33143316 // iterations are not required for correctness, or N - Step, otherwise. Step
33153317 // is equal to the vectorization factor (number of SIMD elements) times the
33163318 // unroll factor (number of SIMD instructions).
3317- VPValue *R = Builder.createNaryOp (Instruction::URem, {TC, Step},
3318- DebugLoc::getUnknown (), " n.mod.vf" );
3319+ VPValue *R =
3320+ Builder.createNaryOp (Instruction::URem, {TC, Step},
3321+ DebugLoc::getCompilerGenerated (), " n.mod.vf" );
33193322
33203323 // There are cases where we *must* run at least one iteration in the remainder
33213324 // loop. See the cost model for when this can happen. If the step evenly
@@ -3330,7 +3333,7 @@ void VPlanTransforms::materializeVectorTripCount(VPlan &Plan,
33303333 }
33313334
33323335 auto Res = Builder.createNaryOp (Instruction::Sub, {TC, R},
3333- DebugLoc::getUnknown (), " n.vec" );
3336+ DebugLoc::getCompilerGenerated (), " n.vec" );
33343337 Plan.getVectorTripCount ().replaceAllUsesWith (Res);
33353338}
33363339
0 commit comments