-   Notifications  You must be signed in to change notification settings 
- Fork 15k
 [LoopInterchange] Bail out when finding a dependency with all * elements #149049 
 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 
  5 commits   Select commit Hold shift + click to select a range 
 24a7257  [LoopInterchange] Exit early when all loops have deps in all directions 
  kasuga-fj 144582a  Merge branch 'main' into feature/loop-interchange-early-exit 
  kasuga-fj 5502f32  Merge branch 'main' into loop-interchange-early-exit 
  kasuga-fj c51edff  fix test 
  kasuga-fj 0e4e759  adjust comment 
  kasuga-fj 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   
     | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| ; RUN: opt < %s -passes=loop-interchange -pass-remarks-output=%t \ | ||
| ; RUN: -disable-output | ||
| ; RUN: FileCheck -input-file %t %s | ||
|  | ||
| ; Check that loop interchange bails out early when finding a direction vector | ||
| ; with all '*' elements. | ||
| ; | ||
| ; for (int i = 0; i < 4; i++) | ||
| ; for (int j = 0; j < 4; j++) | ||
| ; A[i & val][j & val] = 0; | ||
|  | ||
| ; CHECK: --- !Missed | ||
| ; CHECK-NEXT: Pass: loop-interchange | ||
| ; CHECK-NEXT: Name: Dependence | ||
| ; CHECK-NEXT: Function: f | ||
| ; CHECK-NEXT: Args: | ||
| ; CHECK-NEXT: - String: All loops have dependencies in all directions. | ||
| ; CHECK-NEXT: ... | ||
| define void @f(ptr %A, i64 %val) { | ||
| entry: | ||
| br label %for.i.header | ||
|  | ||
| for.i.header: | ||
| %i = phi i64 [ 0, %entry ], [ %i.next, %for.i.latch ] | ||
| br label %for.j | ||
|  | ||
| for.j: | ||
| %j = phi i64 [ 0, %for.i.header ], [ %j.next, %for.j ] | ||
| %subscript.0 = and i64 %i, %val | ||
| %subscript.1 = and i64 %j, %val | ||
| %idx = getelementptr inbounds [4 x i8], ptr %A, i64 %subscript.0, i64 %subscript.1 | ||
| store i8 0, ptr %idx | ||
| %j.next = add nuw nsw i64 %j, 1 | ||
| %exit.j = icmp eq i64 %j.next, 4 | ||
| br i1 %exit.j, label %for.i.latch, label %for.j | ||
|  | ||
| for.i.latch: | ||
| %i.next = add nuw nsw i64 %i, 1 | ||
| %exit.i = icmp eq i64 %i.next, 4 | ||
| br i1 %exit.i, label %exit, label %for.i.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   
     | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| ; REQUIRES: asserts | ||
| ; RUN: opt < %s -passes=loop-interchange -verify-dom-info -verify-loop-info \ | ||
| ; RUN: -disable-output -debug 2>&1 | FileCheck %s | ||
| ; RUN: opt < %s -passes=loop-interchange -pass-remarks-output=%t \ | ||
| ; RUN: -disable-output | ||
| ; RUN: FileCheck -input-file %t %s | ||
|  | ||
| ;; In the following case, p0 and p1 may alias, so the direction vector must be [* *]. | ||
| ;; | ||
|  | @@ -10,9 +10,13 @@ | |
| ;; p0[4 * i + j] = p1[4 * j + i]; | ||
| ;; } | ||
|  | ||
| ; CHECK: Dependency matrix before interchange: | ||
| ; CHECK-NEXT: * * | ||
| ; CHECK-NEXT: Processing InnerLoopId = 1 and OuterLoopId = 0 | ||
| ; CHECK: --- !Missed | ||
| ; CHECK-NEXT: Pass: loop-interchange | ||
| ; CHECK-NEXT: Name: Dependence | ||
| ; CHECK-NEXT: Function: may_alias | ||
| ; CHECK-NEXT: Args: | ||
| ; CHECK-NEXT: - String: All loops have dependencies in all directions. | ||
| ; CHECK-NEXT: ... | ||
|  Comment on lines  -13  to  +19   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. Changed because the previous CHECK directives check the debug outputs, which are no longer printed due to this change. | ||
| define void @may_alias(ptr %p0, ptr %p1) { | ||
| entry: | ||
| br label %for.i.header | ||
|  | ||
   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 | 
|---|---|---|
|  | @@ -2,14 +2,13 @@ | |
| ; RUN: opt < %s -passes=loop-interchange -S -debug 2>&1 | FileCheck %s | ||
|  | ||
| ; CHECK: Dependency matrix before interchange: | ||
| ; CHECK-NEXT: * * | ||
| ; CHECK-NEXT: = * | ||
| ; CHECK-NEXT: < * | ||
| ; CHECK-NEXT: Processing InnerLoopId | ||
|  | ||
| ; This example is taken from github issue #54176 | ||
| ; | ||
| define void @foo(i32 noundef %n, i32 noundef %m, ptr nocapture noundef %aa, ptr nocapture noundef readonly %bb, ptr nocapture noundef writeonly %cc) { | ||
| define void @foo(i32 noundef %n, i32 noundef %m, ptr nocapture noundef noalias %aa, ptr nocapture noundef readonly noalias %bb, ptr nocapture noundef writeonly noalias %cc) { | ||
|  Comment on lines  -5  to  +11   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. Added  | ||
| entry: | ||
| %arrayidx7 = getelementptr inbounds i8, ptr %aa, i64 512 | ||
| br label %for.cond1.preheader | ||
|  | ||
 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.
Can be reworded to the following for clarity.
// If all the elements of any direction vector have only '*', legality can't be proven.
// Exit early to save compile time.
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.
fixed, thanks