[libc-commits] [lld] [compiler-rt] [libcxx] [libclc] [lldb] [llvm] [clang-tools-extra] [libc] [libcxxabi] [flang] [clang] [VPlan] Add new VPScalarCastRecipe, use for IV & step trunc. (PR #78113)
via libc-commits
libc-commits at lists.llvm.org
Thu Jan 25 14:20:45 PST 2024
================
@@ -491,17 +491,39 @@ void VPlanTransforms::removeDeadRecipes(VPlan &Plan) {
static VPValue *createScalarIVSteps(VPlan &Plan, const InductionDescriptor &ID,
ScalarEvolution &SE, Instruction *TruncI,
- Type *IVTy, VPValue *StartV,
- VPValue *Step) {
+ VPValue *StartV, VPValue *Step) {
VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion()->getEntryBasicBlock();
auto IP = HeaderVPBB->getFirstNonPhi();
VPCanonicalIVPHIRecipe *CanonicalIV = Plan.getCanonicalIV();
- Type *TruncTy = TruncI ? TruncI->getType() : IVTy;
- VPValue *BaseIV = CanonicalIV;
- if (!CanonicalIV->isCanonical(ID.getKind(), StartV, Step, TruncTy)) {
- BaseIV = new VPDerivedIVRecipe(ID, StartV, CanonicalIV, Step,
- TruncI ? TruncI->getType() : nullptr);
- HeaderVPBB->insert(BaseIV->getDefiningRecipe(), IP);
+ VPSingleDefRecipe *BaseIV = CanonicalIV;
+ if (!CanonicalIV->isCanonical(ID.getKind(), StartV, Step)) {
+ BaseIV = new VPDerivedIVRecipe(ID, StartV, CanonicalIV, Step);
+ HeaderVPBB->insert(BaseIV, IP);
+ }
+
+ // Truncate base induction if needed.
+ VPTypeAnalysis TypeInfo(SE.getContext());
+ Type *StepTy = TypeInfo.inferScalarType(Step);
----------------
ayalz wrote:
```suggestion
```
Suffice to define StepTy later, when dealing with the truncation of Step. Here we're dealing with truncating BaseIV, and may be good to define its current/original type instead (using "BaseIVTy" may be confusing or deserves updating due to changing BaseIV and its type).
https://github.com/llvm/llvm-project/pull/78113
More information about the libc-commits
mailing list