================ @@ -498,10 +498,34 @@ static VPValue *createScalarIVSteps(VPlan &Plan, const InductionDescriptor &ID, VPCanonicalIVPHIRecipe *CanonicalIV = Plan.getCanonicalIV(); Type *TruncTy = TruncI ? TruncI->getType() : IVTy; VPValue *BaseIV = CanonicalIV; ---------------- ayalz wrote:
Can we first check if Start and Step are canonical, regardless of types, in order to introduce a VPDerivedIVRecipe, i.e., remove the last Type parameter from isCanonical(): ``` VPSingleDefRecipe *BaseIV = CanonicalIV; // If the induction needs transforming besides truncating, create a // VPDerivedIVRecipe. if (!CanonicalIV->isCanonical(ID.getKind(), StartV, Step)) { BaseIV = new VPDerivedIVRecipe(ID, StartV, CanonicalIV, Step); HeaderVPBB->insert(BaseIV, IP); } ``` then check if BaseIV needs to be truncated: ``` VPTypeAnalysis TypeInfo(SE.getContext()); Type *BaseIVTy = TypeInfo.inferScalarType(BaseIV); if (TruncI && TruncI->getType() != BaseIVTy) { Type *TruncTy = TruncI->getType(); assert(BaseIVTy->getScalarSizeInBits() > TruncTy->getScalarSizeInBits() && BaseIVTy->isIntegerTy() && "Truncation requires an integer step"); BaseIV = new VPScalarCastRecipe(Instruction::Trunc, BaseIV, TruncTy); BaseIVTy = TruncTy; HeaderVPBB->insert(BaseIV, IP); } ``` and finally check if Step needs to be truncated: ``` Type *StepTy = TypeInfo.inferScalarType(Step); if (BaseIVTy != StepTy) { assert(StepTy->getScalarSizeInBits() > BaseIVTy->getScalarSizeInBits() && StepTy->isIntegerTy() && "Not truncating."); Step = new VPScalarCastRecipe(Instruction::Trunc, Step, BaseIVTy); auto *VecPreheader = cast<VPBasicBlock>(Plan.getVectorLoopRegion()->getSinglePredecessor()); VecPreheader->appendRecipe(Step->getDefiningRecipe()); } ``` before creating, inserting and returning `Steps`? Is `IVTy` needed? https://github.com/llvm/llvm-project/pull/78113 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits