-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[VPlan] Implement VPlan-based cost model for VPReduction, VPExtendedReduction and VPMulAccumulateReduction. #113903
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
33b1f60
[VPlan] Impl VPlan-based pattern match for ExtendedRed and MulAccRed.…
ElvisWang123 68fbd70
Partially support Extended-reduction.
ElvisWang123 c8c9d56
Support MulAccRecipe
ElvisWang123 d29a118
Fix servel errors and update tests.
ElvisWang123 e5b50f7
Refactors
ElvisWang123 cc004ff
Fix typos and update printing test
ElvisWang123 b5445ca
Fold reduce.add(zext(mul(sext(A), sext(B)))) into MulAccRecipe when A…
ElvisWang123 1df91d4
Refactor! Reuse functions from VPReductionRecipe.
ElvisWang123 a0b2f30
Refactor! Add comments and refine new recipes.
ElvisWang123 46928bd
Remove underying instruction dependency.
ElvisWang123 35abf19
Revert "Remove underying instruction dependency."
ElvisWang123 453997e
Remove extended instruction after mul in MulAccRecipe.
ElvisWang123 fa4f476
Refactor.
ElvisWang123 86ad2d8
Clamp the range when the ExtendedReduction or MulAcc cost is invalid.
ElvisWang123 594f9e4
Try to not depend on underlying ext/mul instructions and preserve fla…
ElvisWang123 52369d0
Update testcase and fix reduction cost.
ElvisWang123 abc08f3
!fixup. Rebase to upstream `prepareToExecute()` implementation.
ElvisWang123 729a70e
Move VPReductionRecipe inherite from VPRecipeWithIRFlags.
ElvisWang123 ea58282
Only create VPMulAcc/VPExtendedReduction recipe when beneficial. NFC
ElvisWang123 1c22ce2
Merge branch 'main' into vp-arm-mve-transform
ElvisWang123 a987456
!fixup use `auto`
ElvisWang123 6c434c7
!fixup VPReductionRecipe unit tests.
ElvisWang123 f4b1b78
!fixup migrate tryTo* to VPlanTransforms
ElvisWang123 bffcac5
Implement clone() and add some docs.
ElvisWang123 da705f1
Update comments.
ElvisWang123 1dc279e
fix-ReductionEVLRecipe query underlyingInstr().
ElvisWang123 20ea82e
Merge branch 'main' into vp-arm-mve-transform
ElvisWang123 90f9ffa
Update after merge.
ElvisWang123 99512fe
Address comments and split off abstract recipes creation from adjustR…
ElvisWang123 2e4014a
!fixup using foldTailWithEVL.
ElvisWang123 38dd924
!fixup, remove extra debugLoc and move check of EVL out of transforms.
ElvisWang123 602a5e4
Merge branch 'main' into vp-arm-mve-transform
ElvisWang123 1939d44
Update after merge main.
ElvisWang123 2ee6e76
Merge branch 'main' into vp-arm-mve-transform
ElvisWang123 d584fc1
Update after merge. Using runPass::().
ElvisWang123 21b33e6
!fixup, Remove unused check and functions.
ElvisWang123 ae371e5
Merge branch 'main' into vp-arm-mve-transform
ElvisWang123 0d7b7f3
!fixup; Address comments.
ElvisWang123 e12bd04
!fixup, Add Mul cost to prevent FMuladd Reduction cost misaligned.
ElvisWang123 4906637
!Fixup, typo.
ElvisWang123 ca5db10
Merge branch 'main' into vp-arm-mve-transform
ElvisWang123 2fbdc7c
!fixup, Address comments and fix VPReductionRecipe::computeCost
ElvisWang123 38d83bf
Merge branch 'main' into vp-arm-mve-transform
ElvisWang123 3e2acad
Merge branch 'main' into vp-arm-mve-transform
ElvisWang123 d2a5a43
!fixup, Update after merge, using std::array.
ElvisWang123 484f9cc
fixup, formatting.
ElvisWang123 cd86af4
!fixup, address comments.
ElvisWang123 84f8a46
Merge branch 'main' into vp-arm-mve-transform
ElvisWang123 36e1032
!fixup, formatting and address comments.
ElvisWang123 2483a29
!fixup, Update inferScalarType and not clear the VF of plan.
ElvisWang123 56dcd90
!fixup, address comments.
ElvisWang123 26d938a
Merge branch 'main' into vp-arm-mve-transform
ElvisWang123 b32538f
!fixup, address comments.
ElvisWang123 fd539f8
!fixup, address comments and using `transferFlags()` to copy nneg.
ElvisWang123 71c7401
!fixup, address comments.
ElvisWang123 7da7983
!fixup, Add new recipes to mayReadWriteMemory.
ElvisWang123 f4afc2c
Merge branch 'main' into vp-arm-mve-transform
ElvisWang123 7b25767
Fixup after merge.
ElvisWang123 685f217
Merge branch 'main' into vp-arm-mve-transform
ElvisWang123 710df44
Address comments.
ElvisWang123 829cb2a
Merge branch 'main' into vp-arm-mve-transform
ElvisWang123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Address comments and split off abstract recipes creation from adjustR…
…ecipesForReduction.
- Loading branch information
commit 99512fedb0cf7b7b684386cc41624b1036aa8bff
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1578,7 +1578,7 @@ class VPWidenCastRecipe : public VPRecipeWithIRFlags { | |||||
ResultTy(ResultTy) {} | ||||||
|
||||||
VPWidenCastRecipe(Instruction::CastOps Opcode, VPValue *Op, Type *ResultTy, | ||||||
bool IsNonNeg, DebugLoc DL) | ||||||
bool IsNonNeg, DebugLoc DL = {}) | ||||||
: VPRecipeWithIRFlags(VPDef::VPWidenCastSC, Op, NonNegFlagsTy(IsNonNeg), | ||||||
DL), | ||||||
Opcode(Opcode), ResultTy(ResultTy) {} | ||||||
|
@@ -2643,8 +2643,8 @@ class VPReductionRecipe : public VPRecipeWithIRFlags { | |||||
} | ||||||
} | ||||||
|
||||||
// For VPExtendedReductionRecipe. | ||||||
// Note that IsNonNeg flag and the debug location are for extend instruction. | ||||||
/// For VPExtendedReductionRecipe. | ||||||
/// Note that IsNonNeg flag and the debug location are for extend instruction. | ||||||
ElvisWang123 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
VPReductionRecipe(const unsigned char SC, const RecurrenceDescriptor &R, | ||||||
ArrayRef<VPValue *> Operands, VPValue *CondOp, | ||||||
bool IsOrdered, bool IsNonNeg, DebugLoc DL) | ||||||
ElvisWang123 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
@@ -2656,8 +2656,8 @@ class VPReductionRecipe : public VPRecipeWithIRFlags { | |||||
} | ||||||
} | ||||||
|
||||||
// For VPMulAccRecipe. | ||||||
// Note that the NUW/NSW and DL are for mul instruction. | ||||||
/// For VPMulAccumulateReductionRecipe. | ||||||
/// Note that the NUW/NSW and DL are for mul instruction. | ||||||
ElvisWang123 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
VPReductionRecipe(const unsigned char SC, const RecurrenceDescriptor &R, | ||||||
ArrayRef<VPValue *> Operands, VPValue *CondOp, | ||||||
bool IsOrdered, bool NUW, bool NSW, DebugLoc DL) | ||||||
ElvisWang123 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
@@ -2797,22 +2797,19 @@ class VPExtendedReductionRecipe : public VPReductionRecipe { | |||||
DebugLoc RedDL; | ||||||
ElvisWang123 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
public: | ||||||
VPExtendedReductionRecipe(const RecurrenceDescriptor &R, Instruction *RedI, | ||||||
VPValue *ChainOp, VPWidenCastRecipe *Ext, | ||||||
VPValue *CondOp, bool IsOrdered) | ||||||
: VPReductionRecipe(VPDef::VPExtendedReductionSC, R, | ||||||
ArrayRef<VPValue *>({ChainOp, Ext->getOperand(0)}), | ||||||
CondOp, IsOrdered, Ext->isNonNeg(), | ||||||
Ext->getDebugLoc()), | ||||||
ExtOp(Ext->getOpcode()), RedDL(RedI->getDebugLoc()) {} | ||||||
|
||||||
/// Contructor for cloning VPExtendedReductionRecipe. | ||||||
VPExtendedReductionRecipe(VPReductionRecipe *R, VPWidenCastRecipe *Ext) | ||||||
: VPReductionRecipe(VPDef::VPExtendedReductionSC, | ||||||
R->getRecurrenceDescriptor(), | ||||||
{R->getChainOp(), Ext->getOperand(0)}, R->getCondOp(), | ||||||
R->isOrdered(), Ext->isNonNeg(), Ext->getDebugLoc()), | ||||||
ExtOp(Ext->getOpcode()), RedDL(R->getDebugLoc()) {} | ||||||
|
||||||
/// For cloning VPExtendedReductionRecipe. | ||||||
VPExtendedReductionRecipe(VPExtendedReductionRecipe *ExtRed) | ||||||
ElvisWang123 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
: VPReductionRecipe( | ||||||
VPDef::VPExtendedReductionSC, ExtRed->getRecurrenceDescriptor(), | ||||||
ArrayRef<VPValue *>({ExtRed->getChainOp(), ExtRed->getVecOp()}), | ||||||
ExtRed->getCondOp(), ExtRed->isOrdered(), ExtRed->isNonNeg(), | ||||||
ExtRed->getExtDebugLoc()), | ||||||
{ExtRed->getChainOp(), ExtRed->getVecOp()}, ExtRed->getCondOp(), | ||||||
ExtRed->isOrdered(), ExtRed->isNonNeg(), ExtRed->getExtDebugLoc()), | ||||||
ExtOp(ExtRed->getExtOpcode()), RedDL(ExtRed->getRedDebugLoc()) {} | ||||||
|
||||||
~VPExtendedReductionRecipe() override = default; | ||||||
|
@@ -2843,15 +2840,16 @@ class VPExtendedReductionRecipe : public VPReductionRecipe { | |||||
return getRecurrenceDescriptor().getRecurrenceType(); | ||||||
ElvisWang123 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
} | ||||||
|
||||||
/// Is the extend ZExt? | ||||||
bool isZExt() const { return getExtOpcode() == Instruction::ZExt; } | ||||||
|
||||||
/// The Opcode of extend instruction. | ||||||
/// The Opcode of extend recipe. | ||||||
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.
Suggested change
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. Done! |
||||||
Instruction::CastOps getExtOpcode() const { return ExtOp; } | ||||||
|
||||||
/// Return the debug location of the extend instruction. | ||||||
/// Return the debug location of the extend recipe. | ||||||
DebugLoc getExtDebugLoc() const { return getDebugLoc(); } | ||||||
|
||||||
/// Return the debug location of the reduction instruction. | ||||||
/// Return the debug location of the reduction recipe. | ||||||
DebugLoc getRedDebugLoc() const { return RedDL; } | ||||||
}; | ||||||
|
||||||
|
@@ -2865,7 +2863,7 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe { | |||||
Instruction::CastOps ExtOp; | ||||||
|
||||||
/// Non-neg flag of the extend recipe. | ||||||
bool IsNonNeg; | ||||||
bool IsNonNeg = false; | ||||||
|
||||||
/// Debug location of extend recipes will be lowered to. | ||||||
DebugLoc Ext0DL; | ||||||
|
@@ -2878,47 +2876,41 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe { | |||||
bool IsExtended = false; | ||||||
ElvisWang123 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
public: | ||||||
VPMulAccumulateReductionRecipe(const RecurrenceDescriptor &R, | ||||||
Instruction *RedI, VPValue *ChainOp, | ||||||
VPValue *CondOp, bool IsOrdered, | ||||||
VPWidenRecipe *Mul, VPWidenCastRecipe *Ext0, | ||||||
VPMulAccumulateReductionRecipe(VPReductionRecipe *R, VPWidenRecipe *Mul, | ||||||
VPWidenCastRecipe *Ext0, | ||||||
VPWidenCastRecipe *Ext1) | ||||||
: VPReductionRecipe(VPDef::VPMulAccumulateReductionSC, R, | ||||||
ArrayRef<VPValue *>({ChainOp, Ext0->getOperand(0), | ||||||
Ext1->getOperand(0)}), | ||||||
CondOp, IsOrdered, Mul->hasNoUnsignedWrap(), | ||||||
Mul->hasNoSignedWrap(), Mul->getDebugLoc()), | ||||||
: VPReductionRecipe( | ||||||
VPDef::VPMulAccumulateReductionSC, R->getRecurrenceDescriptor(), | ||||||
{R->getChainOp(), Ext0->getOperand(0), Ext1->getOperand(0)}, | ||||||
R->getCondOp(), R->isOrdered(), Mul->hasNoUnsignedWrap(), | ||||||
Mul->hasNoSignedWrap(), Mul->getDebugLoc()), | ||||||
ExtOp(Ext0->getOpcode()), IsNonNeg(Ext0->isNonNeg()), | ||||||
Ext0DL(Ext0->getDebugLoc()), Ext1DL(Ext1->getDebugLoc()), | ||||||
RedDL(RedI->getDebugLoc()) { | ||||||
assert(R.getOpcode() == Instruction::Add && | ||||||
RedDL(R->getDebugLoc()) { | ||||||
assert(getRecurrenceDescriptor().getOpcode() == Instruction::Add && | ||||||
"The reduction instruction in MulAccumulateteReductionRecipe must " | ||||||
"be Add"); | ||||||
IsExtended = true; | ||||||
} | ||||||
|
||||||
VPMulAccumulateReductionRecipe(const RecurrenceDescriptor &R, | ||||||
Instruction *RedI, VPValue *ChainOp, | ||||||
VPValue *CondOp, bool IsOrdered, | ||||||
VPWidenRecipe *Mul) | ||||||
: VPReductionRecipe(VPDef::VPMulAccumulateReductionSC, R, | ||||||
ArrayRef<VPValue *>({ChainOp, Mul->getOperand(0), | ||||||
Mul->getOperand(1)}), | ||||||
CondOp, IsOrdered, Mul->hasNoUnsignedWrap(), | ||||||
Mul->hasNoSignedWrap(), Mul->getDebugLoc()), | ||||||
RedDL(RedI->getDebugLoc()) { | ||||||
assert(R.getOpcode() == Instruction::Add && | ||||||
VPMulAccumulateReductionRecipe(VPReductionRecipe *R, VPWidenRecipe *Mul) | ||||||
: VPReductionRecipe( | ||||||
VPDef::VPMulAccumulateReductionSC, R->getRecurrenceDescriptor(), | ||||||
{R->getChainOp(), Mul->getOperand(0), Mul->getOperand(1)}, | ||||||
R->getCondOp(), R->isOrdered(), Mul->hasNoUnsignedWrap(), | ||||||
Mul->hasNoSignedWrap(), Mul->getDebugLoc()), | ||||||
RedDL(R->getDebugLoc()) { | ||||||
assert(getRecurrenceDescriptor().getOpcode() == Instruction::Add && | ||||||
"The reduction instruction in MulAccumulateReductionRecipe must be " | ||||||
"Add"); | ||||||
} | ||||||
|
||||||
/// Constructor for cloning VPMulAccumulateReductionRecipe. | ||||||
/// For cloning VPMulAccumulateReductionRecipe. | ||||||
VPMulAccumulateReductionRecipe(VPMulAccumulateReductionRecipe *MulAcc) | ||||||
ElvisWang123 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
: VPReductionRecipe( | ||||||
VPDef::VPMulAccumulateReductionSC, | ||||||
MulAcc->getRecurrenceDescriptor(), | ||||||
ArrayRef<VPValue *>({MulAcc->getChainOp(), MulAcc->getVecOp0(), | ||||||
MulAcc->getVecOp1()}), | ||||||
{MulAcc->getChainOp(), MulAcc->getVecOp0(), MulAcc->getVecOp1()}, | ||||||
MulAcc->getCondOp(), MulAcc->isOrdered(), | ||||||
MulAcc->hasNoUnsignedWrap(), MulAcc->hasNoSignedWrap(), | ||||||
MulAcc->getMulDebugLoc()), | ||||||
|
@@ -2970,7 +2962,7 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe { | |||||
return ExtOp == Instruction::CastOps::ZExt; | ||||||
} | ||||||
|
||||||
/// Return the non negative flag for the ext instruction. | ||||||
/// Return the non negative flag of the ext recipe. | ||||||
bool isNonNeg() const { return IsNonNeg; } | ||||||
|
||||||
/// Drop flags in this recipe. | ||||||
|
@@ -2980,14 +2972,14 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe { | |||||
this->IsNonNeg = false; | ||||||
} | ||||||
|
||||||
/// Return debug location of mul instruction. | ||||||
/// Return debug location of mul recipe. | ||||||
DebugLoc getMulDebugLoc() const { return getDebugLoc(); } | ||||||
|
||||||
/// Return debug location of extend instructions. | ||||||
/// Return debug location of extend recipe. | ||||||
DebugLoc getExt0DebugLoc() const { return Ext0DL; } | ||||||
DebugLoc getExt1DebugLoc() const { return Ext1DL; } | ||||||
|
||||||
/// Return the debug location of reduction instruction. | ||||||
/// Return the debug location of reduction recipe. | ||||||
DebugLoc getRedDebugLoc() const { return RedDL; } | ||||||
}; | ||||||
|
||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.