- Notifications
You must be signed in to change notification settings - Fork 15.5k
[DA] Add test for GCD MIV misses dependency due to overflow (NFC) #172002
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
Open
kasuga-fj wants to merge 1 commit into main Choose a base branch from users/kasuga-fj/add-test-gcdmiv-overflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
+84 −0
Conversation
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
Contributor Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced Dec 12, 2025
Member
| @llvm/pr-subscribers-llvm-analysis Author: Ryotaro Kasuga (kasuga-fj) ChangesAdd a test case where GCD MIV misses a dependency due to overflow. This will be fixed by #172003 . Full diff: https://github.com/llvm/llvm-project/pull/172002.diff 1 Files Affected:
diff --git a/llvm/test/Analysis/DependenceAnalysis/gcd-miv-overflow.ll b/llvm/test/Analysis/DependenceAnalysis/gcd-miv-overflow.ll index ff8f32b9c8276..2b00856aa9a52 100644 --- a/llvm/test/Analysis/DependenceAnalysis/gcd-miv-overflow.ll +++ b/llvm/test/Analysis/DependenceAnalysis/gcd-miv-overflow.ll @@ -179,5 +179,89 @@ loop: exit: ret void } + +; // 5*1844674407370955161 == 9223372036854775805 == INT64_MAX - 2, so addrecs don't overflow. +; +; for (i = 0; i < 1844674407370955162; i++) +; for (j = 0; j < 2; j++) { +; offset0 = 5*i - 9223372036854775805*j; +; offset1 = -5*i + 9223372036854775796*j - 1; +; if (offset0 == -5) A[offset0] = 0; +; if (offset1 == -5) A[offset1] = 0; +; } +; +; FIXME: DependenceAnalysis fails to detect dependency between two stores. Also +; GCD MIV misses '='-dependency. +; +; memory accesses | (i,j) == (1844674407370955161,1) | (i,j) == (1844674407370955160,1) +; ------------------------------------|----------------------------------|---------------------------------- +; A[ 5*i - 9223372036854775805*j] | A[-5] | +; A[-5*i + 9223372036854775796*j - 1] | | A[-5] +; +define void @gcdmiv_delta_ovfl2(ptr %A) { +; CHECK-ALL-LABEL: 'gcdmiv_delta_ovfl2' +; CHECK-ALL-NEXT: Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 0, ptr %gep.0, align 1 +; CHECK-ALL-NEXT: da analyze - none! +; CHECK-ALL-NEXT: Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 0, ptr %gep.1, align 1 +; CHECK-ALL-NEXT: da analyze - none! +; CHECK-ALL-NEXT: Src: store i8 0, ptr %gep.1, align 1 --> Dst: store i8 0, ptr %gep.1, align 1 +; CHECK-ALL-NEXT: da analyze - none! +; +; CHECK-GCD-MIV-LABEL: 'gcdmiv_delta_ovfl2' +; CHECK-GCD-MIV-NEXT: Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 0, ptr %gep.0, align 1 +; CHECK-GCD-MIV-NEXT: da analyze - output [* *]! +; CHECK-GCD-MIV-NEXT: Src: store i8 0, ptr %gep.0, align 1 --> Dst: store i8 0, ptr %gep.1, align 1 +; CHECK-GCD-MIV-NEXT: da analyze - output [* <>]! +; CHECK-GCD-MIV-NEXT: Src: store i8 0, ptr %gep.1, align 1 --> Dst: store i8 0, ptr %gep.1, align 1 +; CHECK-GCD-MIV-NEXT: da analyze - output [* *]! +; +entry: + br label %loop.i.header + +loop.i.header: + %i = phi i64 [ 0, %entry ], [ %i.inc, %loop.i.latch ] + %c.i.0 = phi i64 [ 0, %entry ], [ %c.i.0.next, %loop.i.latch ] + %c.i.1 = phi i64 [ -1, %entry ], [ %c.i.1.next, %loop.i.latch ] + br label %loop.j.header + +loop.j.header: + %j = phi i64 [ 0, %loop.i.header ], [ %j.inc, %loop.j.latch ] + %offset.0 = phi i64 [ %c.i.0, %loop.i.header ], [ %offset.0.next, %loop.j.latch ] + %offset.1 = phi i64 [ %c.i.1, %loop.i.header ], [ %offset.1.next, %loop.j.latch ] + %cond.0 = icmp eq i64 %offset.0, -5 + br i1 %cond.0, label %if.then.0, label %loop.j.middle + +if.then.0: + %gep.0 = getelementptr i8, ptr %A, i64 %offset.0 + store i8 0, ptr %gep.0 + br label %loop.j.middle + +loop.j.middle: + %cond.1 = icmp eq i64 %offset.1, -5 + br i1 %cond.1, label %if.then.1, label %loop.j.latch + +if.then.1: + %gep.1 = getelementptr i8, ptr %A, i64 %offset.1 + store i8 0, ptr %gep.1 + br label %loop.j.latch + +loop.j.latch: + %j.inc = add i64 %j, 1 + %offset.0.next = add nsw i64 %offset.0, -9223372036854775805 + %offset.1.next = add nsw i64 %offset.1, 9223372036854775796 + %ec.j = icmp eq i64 %j, 2 + br i1 %ec.j, label %loop.i.latch, label %loop.j.header + +loop.i.latch: + %i.inc = add i64 %i, 1 + %c.i.0.next = add nsw i64 %c.i.0, 5 + %c.i.1.next = add nsw i64 %c.i.1, -5 + %ec.i = icmp eq i64 %i.inc, 1844674407370955162 + br i1 %ec.i, label %exit, label %loop.i.header + +exit: + ret void + +} ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: ; CHECK: {{.*}} |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.

Add a test case where GCD MIV misses a dependency due to overflow. This will be fixed by #172003 .