[llvm] [LV] Emit truncate for widen-induction in VPlan during construction. (PR #225991)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 6 01:57:27 PDT 2026
================
@@ -628,37 +626,22 @@ vputils::getEarlyExits(const VPlan &Plan, const VPBlockBase *MiddleVPBB) {
VPScalarIVStepsRecipe *vputils::createScalarIVSteps(
VPlan &Plan, InductionDescriptor::InductionKind Kind,
Instruction::BinaryOps InductionOpcode, FPMathOperator *FPBinOp,
- Instruction *TruncI, VPValue *StartV, VPValue *Step, DebugLoc DL,
- VPBuilder &Builder, const VPIRFlags::WrapFlagsTy &Flags) {
+ VPValue *StartV, VPValue *Step, DebugLoc DL, VPBuilder &Builder,
+ const VPIRFlags::WrapFlagsTy &Flags) {
VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion();
- VPBasicBlock *HeaderVPBB = LoopRegion->getEntryBasicBlock();
VPValue *CanonicalIV = LoopRegion->getCanonicalIV();
+ Type *CanonicalIVTy = CanonicalIV->getScalarType();
+ Type *StepTy = Step->getScalarType();
+ assert(!CanonicalIVTy->isIntegerTy() || !StepTy->isIntegerTy() ||
+ CanonicalIVTy->getScalarSizeInBits() >=
+ StepTy->getScalarSizeInBits() &&
+ "Truncations reqiures integer type and a narrower step.");
+ if (CanonicalIVTy->isIntegerTy() && StepTy->isIntegerTy() &&
+ CanonicalIVTy->getScalarSizeInBits() > StepTy->getScalarSizeInBits())
----------------
artagnon wrote:
```suggestion
assert(
CanonicalIVTy->getScalarSizeInBits() >=
StepTy->getScalarSizeInBits() &&
"Truncations requires integer type and a narrower step.");
if (CanonicalIVTy->isIntegerTy() && StepTy->isIntegerTy())
```
Typo in "requires". I don't think there's any harm in asserting that CanIVTy's size is geq StepTy's size in the case of FP types?
https://github.com/llvm/llvm-project/pull/225991
More information about the llvm-commits
mailing list