[PATCH] D143422: [LV] Update logic for calculating register usage due to invariants
Sander de Smalen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 22 00:55:25 PST 2023
sdesmalen added inline comments.
================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:6122
+ }
}
----------------
sdesmalen wrote:
> I think you can write the algorithm above a bit shorter using a lambda:
>
> bool IsScalar = all_of(cast<Instruction>(Inst)->users(), [&](User *U) {
> auto *I = dyn_cast<Instruction>(U);
> return !I || TheLoop != LI->getLoopFor(I->getParent()) ||
> isScalarAfterVectorization(I, VFs[i]);
> });
>
> ElementCount VF = IsScalar ? ElementCount::getFixed(1) : VFs[i];
> unsigned ClassID = TTI.getRegisterClassForType(VF.isVector(), Inst->getType());
> Invariant[ClassID] += GetRegusage(Inst->getType(), VF);;
>
> I think you can write the algorithm above a bit shorter using a lambda:
>
> bool IsScalar = all_of(cast<Instruction>(Inst)->users(), [&](User *U) {
> auto *I = dyn_cast<Instruction>(U);
> return !I || TheLoop != LI->getLoopFor(I->getParent()) ||
> isScalarAfterVectorization(I, VFs[i]);
> });
>
> ElementCount VF = IsScalar ? ElementCount::getFixed(1) : VFs[i];
> unsigned ClassID = TTI.getRegisterClassForType(VF.isVector(), Inst->getType());
> Invariant[ClassID] += GetRegusage(Inst->getType(), VF);;
>
@sushgokh did you try the above suggestion?
When I try it locally, all the tests in your patch still pass.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143422/new/
https://reviews.llvm.org/D143422
More information about the llvm-commits
mailing list