-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
JIT: strengthen checking of the loop table #71184
Merged
AndyAyersMS
merged 8 commits into
dotnet:main
from
AndyAyersMS:LoopIntegrityCheckUpdates
Jun 28, 2022
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
eb30313
JIT: strengthen checking of the loop table
AndyAyersMS 6cd5761
opt more phases into post phase checks
AndyAyersMS 09d47cc
even more phases
AndyAyersMS 0b9f8b5
add hoisting, placeholders for missing phases
AndyAyersMS ffe8911
add comment showing when phase checks turn on
AndyAyersMS 9a58468
fix typo
AndyAyersMS 6002912
fix printf arg
AndyAyersMS a6f7a8a
revise per feedback
AndyAyersMS 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
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
|
@@ -3245,7 +3245,7 @@ class Compiler | |
|
||
void lvaSortByRefCount(); | ||
|
||
void lvaMarkLocalVars(); // Local variable ref-counting | ||
PhaseStatus lvaMarkLocalVars(); // Local variable ref-counting | ||
void lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers); | ||
void lvaMarkLocalVars(BasicBlock* block, bool isRecompute); | ||
|
||
|
@@ -4713,7 +4713,7 @@ class Compiler | |
inline bool PreciseRefCountsRequired(); | ||
|
||
// Performs SSA conversion. | ||
void fgSsaBuild(); | ||
PhaseStatus fgSsaBuild(); | ||
|
||
// Reset any data structures to the state expected by "fgSsaBuild", so it can be run again. | ||
void fgResetForSsa(); | ||
|
@@ -4737,7 +4737,7 @@ class Compiler | |
|
||
// Do value numbering (assign a value number to each | ||
// tree node). | ||
void fgValueNumber(); | ||
PhaseStatus fgValueNumber(); | ||
|
||
void fgValueNumberLocalStore(GenTree* storeNode, | ||
GenTreeLclVarCommon* lclDefNode, | ||
|
@@ -5263,12 +5263,12 @@ class Compiler | |
|
||
bool fgUpdateFlowGraph(bool doTailDup = false); | ||
|
||
void fgFindOperOrder(); | ||
PhaseStatus fgFindOperOrder(); | ||
|
||
// method that returns if you should split here | ||
typedef bool(fgSplitPredicate)(GenTree* tree, GenTree* parent, fgWalkData* data); | ||
|
||
void fgSetBlockOrder(); | ||
PhaseStatus fgSetBlockOrder(); | ||
|
||
void fgRemoveReturnBlock(BasicBlock* block); | ||
|
||
|
@@ -5917,7 +5917,7 @@ class Compiler | |
|
||
protected: | ||
// Do hoisting for all loops. | ||
void optHoistLoopCode(); | ||
PhaseStatus optHoistLoopCode(); | ||
|
||
// To represent sets of VN's that have already been hoisted in outer loops. | ||
typedef JitHashTable<ValueNum, JitSmallPrimitiveKeyFuncs<ValueNum>, bool> VNSet; | ||
|
@@ -5958,17 +5958,10 @@ class Compiler | |
|
||
// Do hoisting of all loops nested within loop "lnum" (an index into the optLoopTable), followed | ||
// by the loop "lnum" itself. | ||
// | ||
// "m_pHoistedInCurLoop" helps a lot in eliminating duplicate expressions getting hoisted | ||
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. Any reason this comment was deleted? 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. Looks like an inadvertent edit -- at one point I had modified the signature of optHoistLoopNest. |
||
// and reducing the count of total expressions hoisted out of loop. When calculating the | ||
// profitability, we compare this with number of registers and hence, lower the number of expressions | ||
// getting hoisted, better chances that they will get enregistered and CSE considering them. | ||
// | ||
void optHoistLoopNest(unsigned lnum, LoopHoistContext* hoistCtxt); | ||
bool optHoistLoopNest(unsigned lnum, LoopHoistContext* hoistCtxt); | ||
|
||
// Do hoisting for a particular loop ("lnum" is an index into the optLoopTable.) | ||
// Returns the new preheaders created. | ||
void optHoistThisLoop(unsigned lnum, LoopHoistContext* hoistCtxt, BasicBlockList* existingPreHeaders); | ||
bool optHoistThisLoop(unsigned lnum, LoopHoistContext* hoistCtxt, BasicBlockList* existingPreHeaders); | ||
|
||
// Hoist all expressions in "blocks" that are invariant in loop "loopNum" (an index into the optLoopTable) | ||
// outside of that loop. | ||
|
@@ -6018,7 +6011,7 @@ class Compiler | |
void optPerformHoistExpr(GenTree* expr, BasicBlock* exprBb, unsigned lnum); | ||
|
||
public: | ||
void optOptimizeBools(); | ||
PhaseStatus optOptimizeBools(); | ||
|
||
public: | ||
PhaseStatus optInvertLoops(); // Invert loops so they're entered at top and tested at bottom. | ||
|
@@ -6273,6 +6266,7 @@ class Compiler | |
|
||
public: | ||
LoopDsc* optLoopTable; // loop descriptor table | ||
bool optLoopTableValid; // info in loop table should be valid | ||
unsigned char optLoopCount; // number of tracked loops | ||
unsigned char loopAlignCandidates; // number of loops identified for alignment | ||
|
||
|
@@ -6298,7 +6292,7 @@ class Compiler | |
BasicBlock* exit, | ||
unsigned char exitCnt); | ||
|
||
void optClearLoopIterInfo(); | ||
PhaseStatus optClearLoopIterInfo(); | ||
|
||
#ifdef DEBUG | ||
void optPrintLoopInfo(unsigned lnum, bool printVerbose = false); | ||
|
@@ -6909,9 +6903,9 @@ class Compiler | |
GenTree* optPropGetValue(unsigned lclNum, unsigned ssaNum, optPropKind valueKind); | ||
GenTree* optEarlyPropRewriteTree(GenTree* tree, LocalNumberToNullCheckTreeMap* nullCheckMap); | ||
bool optDoEarlyPropForBlock(BasicBlock* block); | ||
bool optDoEarlyPropForFunc(); | ||
void optEarlyProp(); | ||
void optFoldNullCheck(GenTree* tree, LocalNumberToNullCheckTreeMap* nullCheckMap); | ||
bool optDoEarlyPropForFunc(); | ||
PhaseStatus optEarlyProp(); | ||
bool optFoldNullCheck(GenTree* tree, LocalNumberToNullCheckTreeMap* nullCheckMap); | ||
GenTree* optFindNullCheckToFold(GenTree* tree, LocalNumberToNullCheckTreeMap* nullCheckMap); | ||
bool optIsNullCheckFoldingLegal(GenTree* tree, | ||
GenTree* nullCheckTree, | ||
|
@@ -7310,7 +7304,7 @@ class Compiler | |
static void optDumpAssertionIndices(const char* header, ASSERT_TP assertions, const char* footer = nullptr); | ||
static void optDumpAssertionIndices(ASSERT_TP assertions, const char* footer = nullptr); | ||
|
||
void optAddCopies(); | ||
PhaseStatus optAddCopies(); | ||
|
||
/************************************************************************** | ||
* Range checks | ||
|
@@ -7366,9 +7360,6 @@ class Compiler | |
|
||
bool optReachWithoutCall(BasicBlock* srcBB, BasicBlock* dstBB); | ||
|
||
protected: | ||
bool optLoopsMarked; | ||
|
||
/* | ||
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | ||
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | ||
|
This file contains 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 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.
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.
Fix comment