-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[LV] Bundle sub reductions into VPExpressionRecipe #147255
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
Changes from 8 commits
d64d52c
3171e7b
cacb89e
53fca5c
55a9c3e
27e462a
67a0604
33236a3
b988436
0c55abc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1647,12 +1647,12 @@ class TargetTransformInfo { | |||||||||
| TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput) const; | ||||||||||
|
|
||||||||||
| /// Calculate the cost of an extended reduction pattern, similar to | ||||||||||
| /// getArithmeticReductionCost of an Add reduction with multiply and optional | ||||||||||
| /// extensions. This is the cost of as: | ||||||||||
| /// ResTy vecreduce.add(mul (A, B)). | ||||||||||
| /// ResTy vecreduce.add(mul(ext(Ty A), ext(Ty B)). | ||||||||||
| /// getArithmeticReductionCost of an Add/Sub reduction with multiply and | ||||||||||
| /// optional extensions. This is the cost of as: | ||||||||||
| /// ResTy vecreduce.add/sub(mul (A, B)). | ||||||||||
| /// ResTy vecreduce.add/sub(mul(ext(Ty A), ext(Ty B)). | ||||||||||
|
||||||||||
| /// ResTy vecreduce.add/sub(mul (A, B)). | |
| /// ResTy vecreduce.add/sub(mul(ext(Ty A), ext(Ty B)). | |
| /// * ResTy vecreduce.add/sub(mul (A, B)) or, | |
| /// * ResTy vecreduce.add/sub(mul(ext(Ty A), ext(Ty B)). |
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.
Done.
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3151,23 +3151,24 @@ static VPExpressionRecipe * | |||||||||
| tryToMatchAndCreateMulAccumulateReduction(VPReductionRecipe *Red, | ||||||||||
| VPCostContext &Ctx, VFRange &Range) { | ||||||||||
| unsigned Opcode = RecurrenceDescriptor::getOpcode(Red->getRecurrenceKind()); | ||||||||||
| if (Opcode != Instruction::Add) | ||||||||||
| if (Opcode != Instruction::Add && Opcode != Instruction::Sub) | ||||||||||
| return nullptr; | ||||||||||
|
|
||||||||||
| Type *RedTy = Ctx.Types.inferScalarType(Red); | ||||||||||
|
|
||||||||||
| // Clamp the range if using multiply-accumulate-reduction is profitable. | ||||||||||
| auto IsMulAccValidAndClampRange = | ||||||||||
| [&](bool isZExt, VPWidenRecipe *Mul, VPWidenCastRecipe *Ext0, | ||||||||||
| VPWidenCastRecipe *Ext1, VPWidenCastRecipe *OuterExt) -> bool { | ||||||||||
| [&](bool IsZExt, VPWidenRecipe *Mul, VPWidenCastRecipe *Ext0, | ||||||||||
|
||||||||||
| VPWidenCastRecipe *Ext1, VPWidenCastRecipe *OuterExt, | ||||||||||
| unsigned Opcode) -> bool { | ||||||||||
|
||||||||||
| VPWidenCastRecipe *Ext1, VPWidenCastRecipe *OuterExt, | |
| unsigned Opcode) -> bool { | |
| VPWidenCastRecipe *Ext1, VPWidenCastRecipe *OuterExt | |
| ) -> bool { |
Can we just use the captured Opcode?
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.
Done.
Outdated
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.
This rename is NFC, maybe remove it from this PR?
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.
Done.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1468,8 +1468,8 @@ static void analyzeCostOfVecReduction(const IntrinsicInst &II, | |
| TTI::CastContextHint::None, CostKind, RedOp); | ||
|
|
||
| CostBeforeReduction = ExtCost * 2 + MulCost + Ext2Cost; | ||
| CostAfterReduction = | ||
| TTI.getMulAccReductionCost(IsUnsigned, II.getType(), ExtType, CostKind); | ||
| CostAfterReduction = TTI.getMulAccReductionCost( | ||
| IsUnsigned, ReductionOpc, II.getType(), ExtType, CostKind); | ||
|
Comment on lines
+1471
to
+1472
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it would be nice to have a test for this, but not sure if that's possible.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've been trying to make a test but I don't think this code is ever reached. The |
||
| return; | ||
| } | ||
| CostAfterReduction = TTI.getArithmeticReductionCost(ReductionOpc, VecRedTy, | ||
|
|
||
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.
nit:
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.
Done.