-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[llvm][opt][Transforms] Preserve AMDGPU atomic metadata #140314
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
AlexVlx
wants to merge
8
commits into
llvm:main
Choose a base branch
from
AlexVlx:fix_metadata_sinking
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.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
31ceada
Do not drop atomic metadata when combining instructions.
AlexVlx 9e7ca22
Fix formatting.
AlexVlx 8ea68b4
Clean up test.
AlexVlx c6cfed6
Handle all cases.
AlexVlx 401b882
Fix formatting.
AlexVlx c309620
Intersection, not union.
AlexVlx c724475
Fix stray whitespace.
AlexVlx 768c92e
Merge branch 'main' of https://github.com/llvm/llvm-project into fix_…
AlexVlx 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
101 changes: 101 additions & 0 deletions
101
llvm/test/Transforms/SimplifyCFG/merge-amdgpu-atomic-md.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,101 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
;; Test to ensure that AMDGPU atomic related metadata is not dropped when | ||
;; instructions are sunk. Currently the metadata from the first instruction | ||
;; is kept, which prevents full loss of optimisation information. | ||
|
||
; RUN: opt < %s -passes=simplifycfg -sink-common-insts -S | FileCheck %s | ||
|
||
define void @both(i1 %pred0, i1 %pred1, ptr captures(none) %p, double %d) { | ||
; CHECK-LABEL: define void @both( | ||
; CHECK-SAME: i1 [[PRED0:%.*]], i1 [[PRED1:%.*]], ptr captures(none) [[P:%.*]], double [[D:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: [[BRMERGE:%.*]] = select i1 [[PRED0]], i1 true, i1 [[PRED1]] | ||
; CHECK-NEXT: br i1 [[BRMERGE]], label %[[IF_END_SINK_SPLIT:.*]], label %[[IF_END:.*]] | ||
; CHECK: [[IF_END_SINK_SPLIT]]: | ||
; CHECK-NEXT: [[TMP0:%.*]] = atomicrmw fadd ptr [[P]], double [[D]] monotonic, align 8, !amdgpu.no.fine.grained.memory [[META0:![0-9]+]], !amdgpu.no.remote.memory [[META0]] | ||
; CHECK-NEXT: br label %[[IF_END]] | ||
; CHECK: [[IF_END]]: | ||
; CHECK-NEXT: ret void | ||
; | ||
entry: | ||
br i1 %pred0, label %for.body, label %for.body1 | ||
|
||
for.body: | ||
%0 = atomicrmw fadd ptr %p, double %d monotonic, align 8, !amdgpu.no.fine.grained.memory !0, !amdgpu.no.remote.memory !0 | ||
br label %if.end | ||
|
||
for.body1: | ||
br i1 %pred1, label %if.then, label %if.end | ||
|
||
if.then: | ||
%1 = atomicrmw fadd ptr %p, double %d monotonic, align 8, !amdgpu.no.fine.grained.memory !0, !amdgpu.no.remote.memory !0 | ||
br label %if.end | ||
|
||
if.end: | ||
ret void | ||
} | ||
|
||
define void @from(i1 %pred0, i1 %pred1, ptr captures(none) %p, double %d) { | ||
; CHECK-LABEL: define void @from( | ||
; CHECK-SAME: i1 [[PRED0:%.*]], i1 [[PRED1:%.*]], ptr captures(none) [[P:%.*]], double [[D:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: [[BRMERGE:%.*]] = select i1 [[PRED0]], i1 true, i1 [[PRED1]] | ||
; CHECK-NEXT: br i1 [[BRMERGE]], label %[[IF_END_SINK_SPLIT:.*]], label %[[IF_END:.*]] | ||
; CHECK: [[IF_END_SINK_SPLIT]]: | ||
; CHECK-NEXT: [[TMP0:%.*]] = atomicrmw fadd ptr [[P]], double [[D]] monotonic, align 8 | ||
; CHECK-NEXT: br label %[[IF_END]] | ||
; CHECK: [[IF_END]]: | ||
; CHECK-NEXT: ret void | ||
; | ||
entry: | ||
br i1 %pred0, label %for.body, label %for.body1 | ||
|
||
for.body: | ||
%0 = atomicrmw fadd ptr %p, double %d monotonic, align 8, !amdgpu.no.fine.grained.memory !0, !amdgpu.no.remote.memory !0 | ||
br label %if.end | ||
|
||
for.body1: | ||
br i1 %pred1, label %if.then, label %if.end | ||
|
||
if.then: | ||
%1 = atomicrmw fadd ptr %p, double %d monotonic, align 8 | ||
br label %if.end | ||
|
||
if.end: | ||
ret void | ||
} | ||
|
||
define void @to(i1 %pred0, i1 %pred1, ptr captures(none) %p, double %d) { | ||
; CHECK-LABEL: define void @to( | ||
; CHECK-SAME: i1 [[PRED0:%.*]], i1 [[PRED1:%.*]], ptr captures(none) [[P:%.*]], double [[D:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: [[BRMERGE:%.*]] = select i1 [[PRED0]], i1 true, i1 [[PRED1]] | ||
; CHECK-NEXT: br i1 [[BRMERGE]], label %[[IF_END_SINK_SPLIT:.*]], label %[[IF_END:.*]] | ||
; CHECK: [[IF_END_SINK_SPLIT]]: | ||
; CHECK-NEXT: [[TMP0:%.*]] = atomicrmw fadd ptr [[P]], double [[D]] monotonic, align 8 | ||
; CHECK-NEXT: br label %[[IF_END]] | ||
; CHECK: [[IF_END]]: | ||
; CHECK-NEXT: ret void | ||
; | ||
entry: | ||
br i1 %pred0, label %for.body, label %for.body1 | ||
|
||
for.body: | ||
%0 = atomicrmw fadd ptr %p, double %d monotonic, align 8 | ||
br label %if.end | ||
|
||
for.body1: | ||
br i1 %pred1, label %if.then, label %if.end | ||
|
||
if.then: | ||
%1 = atomicrmw fadd ptr %p, double %d monotonic, align 8, !amdgpu.no.fine.grained.memory !0, !amdgpu.no.remote.memory !0 | ||
br label %if.end | ||
|
||
if.end: | ||
ret void | ||
} | ||
|
||
!0 = !{} | ||
;. | ||
; CHECK: [[META0]] = !{} | ||
;. |
Oops, something went wrong.
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.
It looks like all of this metadata accepts an empty node? Using intersect for this doesn't really make sense.