-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[LV] Add scalar load/stores to VPReplicateRecipe::computeCost #153218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-vectorizers @llvm/pr-subscribers-llvm-transforms Author: David Sherwood (david-arm) ChangesAvoid calling getLegacyCost for single scalar loads and stores where the cost is trivial to calculate. Full diff: https://github.com/llvm/llvm-project/pull/153218.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index e34cab117f321..b301aee6dad23 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -2975,6 +2975,22 @@ InstructionCost VPReplicateRecipe::computeCost(ElementCount VF,
Op2Info, Operands, UI, &Ctx.TLI) *
(isSingleScalar() ? 1 : VF.getFixedValue());
}
+ case Instruction::Load:
+ case Instruction::Store: {
+ if (isSingleScalar()) {
+ Type *ValTy = getLoadStoreType(UI);
+ Type *ScalarPtrTy = getLoadStorePointerOperand(UI)->getType();
+ const Align Alignment = getLoadStoreAlignment(UI);
+ unsigned AS = getLoadStoreAddressSpace(UI);
+ TTI::OperandValueInfo OpInfo = TTI::getOperandInfo(UI->getOperand(0));
+ InstructionCost ScalarMemOpCost = Ctx.TTI.getMemoryOpCost(
+ UI->getOpcode(), ValTy, Alignment, AS, CostKind, OpInfo, UI);
+ return ScalarMemOpCost + Ctx.TTI.getAddressComputationCost(ScalarPtrTy);
+ }
+ // TODO: See getMemInstScalarizationCost for how to handle vector and
+ // predicated cases.
+ break;
+ }
}
return Ctx.getLegacyCost(UI, VF);
|
|
Gentle ping. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // TODO: See getMemInstScalarizationCost for how to handle vector and | |
| // TODO: See getMemInstScalarizationCost for how to handle replicating and |
This code here won't handle vector cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get this from the VPlan type analysis?
a4e0e92 to
fd7bf4b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is indeed confusing and the argument isn't documented, but it looks like in RISCV TTI and X86 TTI (https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/X86/X86TargetTransformInfo.cpp#L5241) the argument is used as it is passed here: stored value for stores, address for loads. AArch64 and ARM TTIs don't use it.
So it seems it is used as expected, even though the documentation of the interface could be improved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checking if you saw this comment? Given the above, the comment should be removed here and the documentation for the TTI functions improved/clarified
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sorry just got caught up with other things. I guess I wasn't really sure whether you wanted me to change the documentation in this PR or were just pointing it out for information purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably best to remove the TOOD here and clarify the TTI separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation change: #156875
Avoid calling getLegacyCost for single scalar loads and stores where the cost is trivial to calculate.
fd7bf4b to
adf9af9
Compare
fhahn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/186/builds/12161 Here is the relevant piece of the build log for the reference |
Avoid calling getLegacyCost for single scalar loads and stores where the cost is trivial to calculate.