-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[LV]: Add costs to VPInstruction #125008
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
[LV]: Add costs to VPInstruction #125008
Conversation
- As VPlanTransforms replaces some instructions by VPInstructions, then VPInstruction should have costs. - Use legacy model for now. - Computed costs are for the original/replaced instructions to match with what legacy model computed.
@llvm/pr-subscribers-vectorizers @llvm/pr-subscribers-llvm-transforms Author: Hassnaa Hamdi (hassnaaHamdi) Changes
Full diff: https://github.com/llvm/llvm-project/pull/125008.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index a1ff684b2b8017..8813ea3c208b61 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1315,6 +1315,9 @@ class VPInstruction : public VPRecipeWithIRFlags,
InstructionCost computeCost(ElementCount VF,
VPCostContext &Ctx) const override {
// TODO: Compute accurate cost after retiring the legacy cost model.
+ // Use legacy cost model for now.
+ if (auto *I = dyn_cast_or_null<Instruction>(getUnderlyingValue()))
+ return Ctx.getLegacyCost(I, VF);
return 0;
}
|
@@ -1315,6 +1315,9 @@ class VPInstruction : public VPRecipeWithIRFlags, | |||
InstructionCost computeCost(ElementCount VF, | |||
VPCostContext &Ctx) const override { | |||
// TODO: Compute accurate cost after retiring the legacy cost model. | |||
// Use legacy cost model for now. | |||
if (auto *I = dyn_cast_or_null<Instruction>(getUnderlyingValue())) |
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.
Hi @hassnaaHamdi, I think you should be able to do this without falling back on the legacy cost model. I also plan to put a patch up fairly soon that starts filling this function in properly because it's needed for the early exit work. What instructions were you hitting when getting into this instruction?
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.
The original instruction was 'or disjoint' and it got replaced by the VPlanTransforms to 'Add' instruction wrapped in VPInstruction.
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.
Could you please add a test case, some more details of what VPInstructions need costs now and how this is related to the change for interleaving?
Closing this pull request as the work is done by another patch. |
calculations which may cause choosing VF different than chosen one by legacy cost model.