-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[LoopInterchange] Handle confused dependence correctly #140709
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
6 commits
Select commit
Hold shift + click to select a range
dbe3f60
[LoopInterchange] Remove 'I' dependency
kasuga-fj 860bfdf
Use isConfused
kasuga-fj 28aae4e
Remove unrelated test
kasuga-fj 5b7c40a
Rename the filename of the test
kasuga-fj 6d06eb3
Undo test changes
kasuga-fj f8c4a48
Fix test failure
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
93 changes: 93 additions & 0 deletions
93
llvm/test/Transforms/LoopInterchange/dependence-levels-less-than-loop-depth.ll
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,93 @@ | ||
| ; REQUIRES: asserts | ||
| ; RUN: opt < %s -passes=loop-interchange -verify-dom-info -verify-loop-info \ | ||
| ; RUN: -disable-output -debug 2>&1 | FileCheck %s | ||
|
|
||
| ;; In the following case, p0 and p1 may alias, so the direction vector must be [* *]. | ||
| ;; | ||
| ;; void may_alias(float *p0, float *p1) { | ||
| ;; for (int i = 0; i < 4; i++) | ||
| ;; for (int j = 0; j < 4; j++) | ||
| ;; p0[4 * i + j] = p1[4 * j + i]; | ||
| ;; } | ||
|
|
||
| ; CHECK: Dependency matrix before interchange: | ||
| ; CHECK-NEXT: * * | ||
| ; CHECK-NEXT: Processing InnerLoopId = 1 and OuterLoopId = 0 | ||
| define void @may_alias(ptr %p0, ptr %p1) { | ||
| entry: | ||
| br label %for.i.header | ||
|
|
||
| for.i.header: | ||
| %i = phi i32 [ 0, %entry ], [ %i.inc, %for.i.latch ] | ||
| br label %for.j | ||
|
|
||
| for.j: | ||
| %j = phi i32 [ 0, %for.i.header ], [ %j.inc, %for.j ] | ||
| %idx.0 = getelementptr inbounds [4 x [4 x float]], ptr %p0, i32 0, i32 %j, i32 %i | ||
| %idx.1 = getelementptr inbounds [4 x [4 x float]], ptr %p1, i32 0, i32 %i, i32 %j | ||
| %0 = load float, ptr %idx.0, align 4 | ||
| store float %0, ptr %idx.1, align 4 | ||
| %j.inc = add nuw nsw i32 %j, 1 | ||
| %cmp.j = icmp slt i32 %j.inc, 4 | ||
| br i1 %cmp.j, label %for.j, label %for.i.latch | ||
|
|
||
| for.i.latch: | ||
| %i.inc = add nuw nsw i32 %i, 1 | ||
| %cmp.i = icmp slt i32 %i.inc, 4 | ||
| br i1 %cmp.i, label %for.i.header, label %exit | ||
|
|
||
| exit: | ||
| ret void | ||
| } | ||
|
|
||
| @A = global [4 x [4 x [4 x float]]] zeroinitializer, align 4 | ||
| @V = global [4 x float] zeroinitializer, align 4 | ||
|
|
||
| ;; In the following case, there is an all direction dependence for the j-loop | ||
| ;; and k-loop. | ||
| ;; | ||
| ;; for (int i = 0; i < 4; i++) | ||
| ;; for (int j = 0; j < 4; j++) | ||
| ;; for (int k = 0; k < 4; k++) | ||
| ;; V[i] += A[i][j][k]; | ||
|
|
||
| ; CHECK: Dependency matrix before interchange: | ||
| ; CHECK-NEXT: = * * | ||
| ; CHECK-NEXT: Processing InnerLoopId = 2 and OuterLoopId = 1 | ||
| define void @partial_reduction() { | ||
|
||
| entry: | ||
| br label %for.i.header | ||
|
|
||
| for.i.header: | ||
| %i = phi i32 [ 0, %entry ], [ %i.inc, %for.i.latch ] | ||
| br label %for.j.header | ||
|
|
||
| for.j.header: | ||
| %j = phi i32 [ 0, %for.i.header ], [ %j.inc, %for.j.latch ] | ||
| br label %for.k | ||
|
|
||
| for.k: | ||
| %k = phi i32 [ 0, %for.j.header ], [ %k.inc, %for.k ] | ||
| %idx.a = getelementptr inbounds [4 x [4 x [4 x float]]], ptr @A, i32 0, i32 %i, i32 %j, i32 %k | ||
| %idx.v = getelementptr inbounds [4 x float], ptr @V, i32 0, i32 %i | ||
| %0 = load float, ptr %idx.a, align 4 | ||
| %1 = load float, ptr %idx.v, align 4 | ||
| %add = fadd fast float %0, %1 | ||
| store float %add, ptr %idx.v, align 4 | ||
| %k.inc = add nuw nsw i32 %k, 1 | ||
| %cmp.k = icmp slt i32 %k.inc, 4 | ||
| br i1 %cmp.k, label %for.k, label %for.j.latch | ||
|
|
||
| for.j.latch: | ||
| %j.inc = add nuw nsw i32 %j, 1 | ||
| %cmp.j = icmp slt i32 %j.inc, 4 | ||
| br i1 %cmp.j, label %for.j.header, label %for.i.latch | ||
|
|
||
| for.i.latch: | ||
| %i.inc = add nuw nsw i32 %i, 1 | ||
| %cmp.i = icmp slt i32 %i.inc, 4 | ||
| br i1 %cmp.i, label %for.i.header, label %exit | ||
|
|
||
| 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.
Uh oh!
There was an error while loading. Please reload this page.
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.
DependenceInfo does not consider commutativity (I think that what you mean). If
vis an array of floats, it wouldn't even be correct without-ffast-math.Since determining commutativity is currently not implemented in LoopInterchange, the TODO related to this seems misleading.
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, that is what I meant, and my comment isn't correct.
You're right, I'll delete it.