-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[LoopInterchange] Forbid interchange when the dependency is confused #78533
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| ; REQUIRES: asserts | ||
| ; RUN: opt < %s -passes=loop-interchange -cache-line-size=64 -verify-dom-info -verify-loop-info \ | ||
| ; RUN: -S -debug 2>&1 | FileCheck %s | ||
|
Comment on lines
+2
to
+3
Contributor
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.
|
||
|
|
||
| ;; Test that a confused dependency in loop should prevent interchange in | ||
| ;; loops i and j. | ||
| ;; | ||
| ;; void test_deps() { | ||
| ;; for (int i = 0; i <= 3; i++) | ||
| ;; for (int j = 0; j <= 3; j++) { | ||
| ;; *f ^= 0x1000; | ||
| ;; c[j][i] = *f; | ||
| ;; } | ||
| ;; } | ||
|
|
||
|
|
||
| ; CHECK: Confused dependency between: | ||
| ; CHECK: store i32 %xor, ptr %arrayidx6, align 4 | ||
| ; CHECK: %1 = load i32, ptr %0, align 4 | ||
| ; CHECK-NOT: Loops interchanged. | ||
|
|
||
| @a = global i32 0, align 4 | ||
| @f = global ptr @a, align 8 | ||
| @c = global [4 x [4 x i32]] zeroinitializer, align 8 | ||
|
Comment on lines
+22
to
+24
Contributor
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. Do these need to be globals? Can they not be passed as arguments to the function? |
||
|
|
||
| define void @test_deps() { | ||
|
Contributor
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. I would recommend naming this function |
||
| entry: | ||
| %0 = load ptr, ptr @f, align 8 | ||
| br label %for.cond1.preheader | ||
|
|
||
| ; Loop: | ||
| for.cond1.preheader: ; preds = %entry, %for.cond.cleanup3 | ||
| %indvars.iv16 = phi i64 [ 0, %entry ], [ %indvars.iv.next17, %for.cond.cleanup3 ] | ||
| br label %for.body4 | ||
|
|
||
| for.cond.cleanup3: ; preds = %for.body4 | ||
| %indvars.iv.next17 = add nuw nsw i64 %indvars.iv16, 1 | ||
| %exitcond18 = icmp ne i64 %indvars.iv.next17, 4 | ||
| br i1 %exitcond18, label %for.cond1.preheader, label %for.cond.cleanup | ||
|
|
||
| for.body4: ; preds = %for.cond1.preheader, %for.body4 | ||
| %indvars.iv = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next, %for.body4 ] | ||
| %1 = load i32, ptr %0, align 4 | ||
| %xor = xor i32 %1, 4096 | ||
| store i32 %xor, ptr %0, align 4 | ||
| %arrayidx6 = getelementptr inbounds [4 x [4 x i32]], ptr @c, i64 0, i64 %indvars.iv, i64 %indvars.iv16 | ||
| store i32 %xor, ptr %arrayidx6, align 4 | ||
| %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 | ||
| %exitcond = icmp ne i64 %indvars.iv.next, 4 | ||
| br i1 %exitcond, label %for.body4, label %for.cond.cleanup3 | ||
|
Comment on lines
+42
to
+50
Contributor
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. It would be nice if the test were cleaned up a bit. Example: s/indvars.iv/iv.inner/, s/for.body.4/inner.loop/, s/for.cond1.preheader/outer.loop/? |
||
|
|
||
| ; Exit blocks | ||
| for.cond.cleanup: ; preds = %for.cond.cleanup3 | ||
| ret void | ||
| } | ||
|
Contributor
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. Was this test faulty? |
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.
Are all these other
noaliaschanges required as part of the patch? If so, I can recommend marking both argumentsnoalias, and mentioning why in the commit message (eg. if these tests were faulty to begin with).