[llvm] [VPlan] Add VPInstruction::StepVector and use it in VPWidenIntOrFpInductionRecipe (PR #129508)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 22 00:44:53 PDT 2025
================
@@ -2410,6 +2410,23 @@ void VPlanTransforms::convertToConcreteRecipes(VPlan &Plan,
continue;
}
+ if (auto *IVR = dyn_cast<VPWidenIntOrFpInductionRecipe>(&R)) {
+ // Infer an up-to-date type since
+ // optimizeVectorInductionWidthForTCAndVFUF may have truncated the start
+ // and step values.
+ Type *Ty = TypeInfo.inferScalarType(IVR->getStartValue());
+ if (TruncInst *Trunc = IVR->getTruncInst())
+ Ty = Trunc->getType();
+ if (Ty->isFloatingPointTy())
+ Ty = IntegerType::get(Ty->getContext(), Ty->getScalarSizeInBits());
+ VPInstruction *StepVector = new VPInstructionWithType(
+ VPInstruction::StepVector, {}, Ty, R.getDebugLoc());
----------------
lukel97 wrote:
Oh I forgot you had added a builder method for VPInstructionWithType, I've used it in 83fafe3e19868c0fd73c6a50208775c4ea511f80. I had to edit it though to only call the FMF constructor if FMFs were present, otherwise it triggers the `assert(isFPMathOp() && "this op can't take fast-math flags");` in VPInstruction because StepVector doesn't take the flags
https://github.com/llvm/llvm-project/pull/129508
More information about the llvm-commits
mailing list