-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Exclusivity] Add new dominating access checks in loop pre-headers #20232
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
@swift-ci Please test |
@eeckstein , @atrick Can either one of you please review? |
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.
I don't see any major issues, but I don't want to claim that I've fully reviewed it yet. I have some clarification request and style suggestions:
-
I thought you would potentially need to rerun the normal dominated check removal after loop dominated removal. Can you come up with an example where that's needed, or do you want to put that off as a TODO for later? It seems possible that this will create redundant accesses in the preheader.
-
LoopDominatedAccessAdder makes some key assumptions. They should be explicitly stated somewhere:
-
Precondition: There are no unpaired accesses (or keypath accesses) anywhere in the function.
-
Invariant: An access scope cannot begin outside the loop and end on any path between the loop header and the original dominated access.
-
Expectation: Accesses will be hoisted across nested loops during bottom-up processing.
protected: | ||
/// \brief Collect a set of instructions that can be dominated | ||
void | ||
analyzeCurrentLoop(SILLoop *currnetLoop, |
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.
currnet
typo.
continue; | ||
} | ||
auto operand = beginAccess->getOperand(); | ||
if (auto *defInstr = operand->getDefiningInstruction()) { |
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.
Use getParentBlock
instead of duplicating all this code. It works for instructions and arguments.
|
||
static bool skipAccess(DominanceInfo *domInfo, SILValue &operand, | ||
SILBasicBlock *preheader, TermInst *preheaderTerm) { | ||
if (auto *defInstr = operand->getDefiningInstruction()) { |
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.
You can replace this whole function with a call to getParentBlock
followed by a single domanince check between the operand's block and the preheader block. Also, I think this dominance check should be an assert, if I understand the preconditions.
319ba6d
to
f2d3be5
Compare
General case: <loop preheader> A = ref_element_addr <loop> begin_access A [dynamic] [no_nested_conflict] Adding an empty begin_access A in the preheader would allow us to turn the loop's access to [static]
f2d3be5
to
2e237f4
Compare
Thanks @atrick - I changed the PR based on your comments and explicitly stated the assumptions you mentioned.
|
@swift-ci Please test |
radar rdar://problem/45736229
General case:
A = ref_element_addr
begin_access A [dynamic] [no_nested_conflict]
Adding an empty begin_access A in the preheader would allow us to turn the loop's access to [static]
This improves the performance of matrix multiplication by 2X