-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[LoopInterchange] Hoist isComputableLoopNest() in the control flow #124247
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 all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fad4645
[LoopInterchange] Hoist isCompuatableLoopNest() in the control flow
madhur13490 1d9e54a
Update tests to account for new remarks
madhur13490 7e2710c
Address formatting issues
madhur13490 31f9942
Address review comments
madhur13490 1e95541
Change to RemarksAnalysis
madhur13490 d351384
Add simplified test
madhur13490 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 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
52 changes: 52 additions & 0 deletions
52
llvm/test/Transforms/LoopInterchange/no-dependence-info.ll
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. Could you please add a brief comment describing what this test checks? 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 |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
; RUN: opt %s -passes='loop-interchange' -pass-remarks=loop-interchange -disable-output 2>&1 | FileCheck --allow-empty %s | ||
|
||
target triple = "aarch64-unknown-linux-gnu" | ||
|
||
; CHECK-NOT: Computed dependence info, invoking the transform. | ||
|
||
; For the below test, backedge count cannot be computed. | ||
; Computing backedge count requires only SCEV and should | ||
; not require dependence info. | ||
; | ||
; void bar(int m, int n) { | ||
; for (unsigned int i = 0; i < m; ++i) { | ||
; for (unsigned int j = 0; j < m; ++j) { | ||
; // dummy code | ||
; } | ||
; } | ||
;} | ||
|
||
define void @bar(i32 %m, i32 %n) | ||
{ | ||
entry: | ||
br label %outer.header | ||
|
||
outer.header: | ||
%m_temp1 = phi i32 [%m, %entry], [%m_temp, %outer.latch] | ||
br label %inner.header | ||
|
||
|
||
inner.header: | ||
%n_temp1 = phi i32 [%n, %outer.header], [%n_temp, %inner.latch] | ||
|
||
br label %body | ||
|
||
body: | ||
; dummy code | ||
|
||
br label %inner.latch | ||
|
||
inner.latch: | ||
%n_temp = add i32 %n_temp1, 1 | ||
%cmp2 = icmp eq i32 %n_temp, 1 | ||
br i1 %cmp2, label %outer.latch, label %inner.header | ||
|
||
outer.latch: | ||
%m_temp = add i32 %n, 1 | ||
%cmp3 = icmp eq i32 %m_temp, 1 | ||
br i1 %cmp3, label %exit, label %outer.header | ||
|
||
exit: | ||
ret void | ||
} | ||
|
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
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
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.
This is a user-facing optimisation remark, but it is quite "technical".
Correct me if I am wrong, but I think what we are trying to say here is equivalent to this:
in function
processLoop
on line525
.My question is: can we turn this debug message into an OptimisationRemark and not need this new opt remark? I think this could serve two purposes: it is actually interesting information for users, and does it help you with knowing that "dep info has been computed, the transformation is legal"?
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.
As discussed above, I think this message is just for testing that the process exits before computing dependence info if the loop is not computable. To achieve this, inserting a new message here seems to be reasonable to me.
However, in terms of messages to users, I think this is a bit excessive or noisy. Replacing it with
dbgs()
would be one option. It depends on which what we want to prioritize: test coverage or having useful "technical" messages for users.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 was wondering if the state that we are trying to capture here (interchange is legal, but unknown if profitable) is caught by the "Loops are legal to interchange" debug message so that we can change that in an optimisation remark and don't need this new one.
Alternatively, I don't mind changing this optimisation remark in a debug message. In general I don't like tests that rely on debug builds, but this is an exception that would be okay I think.
But I don't have strong opinions on this to be honest, so WDYIT @madhur13490 ?
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.
Sorry for chipping in many times, but I don't think what we want to capture here is "interchange is legal", I think it is something like "This loop form is not supported, so we will not continue the following processes (including the legality check)". Let me know if I'm wrong.
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.
Yes, I agree with @kasuga-fj. At this point in the code, we cannot guarantee that the loop nest is legal. For example, if Outer most loop does not have unique exit then transform can terminate. (line 489 )
(I do plan to pull that check up too, but that is of lower priority.)