-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[llvm][AMDGPU] Fold llvm.amdgcn.wavefrontsize
early
#114481
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
22 commits
Select commit
Hold shift + click to select a range
3ba88ce
Add pass to handle AMDGCN pseudo-intrinsics (abstract placeholders fo…
AlexVlx 1376596
Merge branch 'main' of https://github.com/llvm/llvm-project into hand…
AlexVlx 826c291
Implement review feedback.
AlexVlx ab6f5a2
Do not fold early for `generic` mcpu.
AlexVlx f8705fb
Fix formatting (again).
AlexVlx ed870a8
Merge branch 'main' of https://github.com/llvm/llvm-project into hand…
AlexVlx f5751a5
Merge branch 'main' of https://github.com/llvm/llvm-project into hand…
AlexVlx 026ed00
Remove pass, fold in InstCombine.
AlexVlx 195decc
Remove leftovers.
AlexVlx 1a7abaf
Remove pass.
AlexVlx 9aed76c
Fix formatting.
AlexVlx 246c22f
Really fix formatting.
AlexVlx 5a11720
Merge branch 'main' of https://github.com/llvm/llvm-project into hand…
AlexVlx 7cf7558
Split tests.
AlexVlx 6a77b8a
Merge branch 'main' of https://github.com/llvm/llvm-project into hand…
AlexVlx be414a8
Merge branch 'main' of https://github.com/llvm/llvm-project into hand…
AlexVlx dedc593
Merge branch 'main' of https://github.com/llvm/llvm-project into hand…
AlexVlx c634b4e
Merge branch 'main' of https://github.com/llvm/llvm-project into hand…
AlexVlx c7be46f
Merge branch 'handle_wavefrontsize_early' of https://github.com/AlexV…
AlexVlx ed9f19f
Tweak `generic` mcpu handling.
AlexVlx d30cb95
Merge branch 'main' of https://github.com/llvm/llvm-project into hand…
AlexVlx dcfe7be
Use `isWaveSizeKnown` instead of gnarly hack.
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
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
114 changes: 114 additions & 0 deletions
114
llvm/test/Transforms/InstCombine/AMDGPU/llvm.amdgcn.wavefrontsize.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,114 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt -mtriple=amdgcn-- -passes=instcombine -S < %s | FileCheck -check-prefix=OPT %s | ||
; RUN: opt -mtriple=amdgcn-- -mattr=+wavefrontsize32 -passes=instcombine -S < %s | FileCheck -check-prefix=OPT-W32 %s | ||
; RUN: opt -mtriple=amdgcn-- -mattr=+wavefrontsize64 -passes=instcombine -S < %s | FileCheck -check-prefix=OPT-W64 %s | ||
; RUN: opt -mtriple=amdgcn-- -mcpu=tonga -passes=instcombine -S < %s | FileCheck -check-prefix=OPT-W64 %s | ||
; RUN: opt -mtriple=amdgcn-- -mcpu=gfx1010 -mattr=+wavefrontsize32 -passes=instcombine -S < %s | FileCheck -check-prefix=OPT-W32 %s | ||
; RUN: opt -mtriple=amdgcn-- -mcpu=gfx1010 -mattr=+wavefrontsize64 -passes=instcombine -S < %s | FileCheck -check-prefix=OPT-W64 %s | ||
; RUN: opt -mtriple=amdgcn-- -mcpu=gfx1100 -mattr=+wavefrontsize32 -passes=instcombine -S < %s | FileCheck -check-prefix=OPT-W32 %s | ||
; RUN: opt -mtriple=amdgcn-- -mcpu=gfx1100 -mattr=+wavefrontsize64 -passes=instcombine -S < %s | FileCheck -check-prefix=OPT-W64 %s | ||
|
||
define amdgpu_kernel void @fold_wavefrontsize(ptr addrspace(1) nocapture %arg) { | ||
; OPT-LABEL: define amdgpu_kernel void @fold_wavefrontsize( | ||
; OPT-SAME: ptr addrspace(1) nocapture [[ARG:%.*]]) { | ||
; OPT-NEXT: [[BB:.*:]] | ||
; OPT-NEXT: [[TMP:%.*]] = tail call i32 @llvm.amdgcn.wavefrontsize() #[[ATTR1:[0-9]+]] | ||
; OPT-NEXT: store i32 [[TMP]], ptr addrspace(1) [[ARG]], align 4 | ||
; OPT-NEXT: ret void | ||
; | ||
; OPT-W32-LABEL: define amdgpu_kernel void @fold_wavefrontsize( | ||
; OPT-W32-SAME: ptr addrspace(1) nocapture [[ARG:%.*]]) #[[ATTR0:[0-9]+]] { | ||
; OPT-W32-NEXT: [[BB:.*:]] | ||
; OPT-W32-NEXT: store i32 32, ptr addrspace(1) [[ARG]], align 4 | ||
; OPT-W32-NEXT: ret void | ||
; | ||
; OPT-W64-LABEL: define amdgpu_kernel void @fold_wavefrontsize( | ||
; OPT-W64-SAME: ptr addrspace(1) nocapture [[ARG:%.*]]) #[[ATTR0:[0-9]+]] { | ||
; OPT-W64-NEXT: [[BB:.*:]] | ||
; OPT-W64-NEXT: store i32 64, ptr addrspace(1) [[ARG]], align 4 | ||
; OPT-W64-NEXT: ret void | ||
; | ||
bb: | ||
%tmp = tail call i32 @llvm.amdgcn.wavefrontsize() #0 | ||
store i32 %tmp, ptr addrspace(1) %arg, align 4 | ||
ret void | ||
} | ||
|
||
define amdgpu_kernel void @fold_and_optimize_wavefrontsize(ptr addrspace(1) nocapture %arg) { | ||
; OPT-LABEL: define amdgpu_kernel void @fold_and_optimize_wavefrontsize( | ||
; OPT-SAME: ptr addrspace(1) nocapture [[ARG:%.*]]) { | ||
; OPT-NEXT: [[BB:.*:]] | ||
; OPT-NEXT: [[TMP:%.*]] = tail call i32 @llvm.amdgcn.wavefrontsize() #[[ATTR1]] | ||
; OPT-NEXT: [[TMP1:%.*]] = icmp ugt i32 [[TMP]], 32 | ||
; OPT-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i32 2, i32 1 | ||
; OPT-NEXT: store i32 [[TMP2]], ptr addrspace(1) [[ARG]], align 4 | ||
; OPT-NEXT: ret void | ||
; | ||
; OPT-W32-LABEL: define amdgpu_kernel void @fold_and_optimize_wavefrontsize( | ||
; OPT-W32-SAME: ptr addrspace(1) nocapture [[ARG:%.*]]) #[[ATTR0]] { | ||
; OPT-W32-NEXT: [[BB:.*:]] | ||
; OPT-W32-NEXT: store i32 1, ptr addrspace(1) [[ARG]], align 4 | ||
; OPT-W32-NEXT: ret void | ||
; | ||
; OPT-W64-LABEL: define amdgpu_kernel void @fold_and_optimize_wavefrontsize( | ||
; OPT-W64-SAME: ptr addrspace(1) nocapture [[ARG:%.*]]) #[[ATTR0]] { | ||
; OPT-W64-NEXT: [[BB:.*:]] | ||
; OPT-W64-NEXT: store i32 2, ptr addrspace(1) [[ARG]], align 4 | ||
; OPT-W64-NEXT: ret void | ||
; | ||
bb: | ||
%tmp = tail call i32 @llvm.amdgcn.wavefrontsize() #0 | ||
%tmp1 = icmp ugt i32 %tmp, 32 | ||
%tmp2 = select i1 %tmp1, i32 2, i32 1 | ||
store i32 %tmp2, ptr addrspace(1) %arg | ||
ret void | ||
} | ||
|
||
define amdgpu_kernel void @fold_and_optimize_if_wavefrontsize(ptr addrspace(1) nocapture %arg) { | ||
; OPT-LABEL: define amdgpu_kernel void @fold_and_optimize_if_wavefrontsize( | ||
; OPT-SAME: ptr addrspace(1) nocapture [[ARG:%.*]]) { | ||
; OPT-NEXT: [[BB:.*:]] | ||
; OPT-NEXT: [[TMP:%.*]] = tail call i32 @llvm.amdgcn.wavefrontsize() #[[ATTR1]] | ||
; OPT-NEXT: [[TMP1:%.*]] = icmp ugt i32 [[TMP]], 32 | ||
; OPT-NEXT: br i1 [[TMP1]], label %[[BB2:.*]], label %[[BB3:.*]] | ||
; OPT: [[BB2]]: | ||
; OPT-NEXT: store i32 1, ptr addrspace(1) [[ARG]], align 4 | ||
; OPT-NEXT: br label %[[BB3]] | ||
; OPT: [[BB3]]: | ||
; OPT-NEXT: ret void | ||
; | ||
; OPT-W32-LABEL: define amdgpu_kernel void @fold_and_optimize_if_wavefrontsize( | ||
; OPT-W32-SAME: ptr addrspace(1) nocapture [[ARG:%.*]]) #[[ATTR0]] { | ||
; OPT-W32-NEXT: [[BB:.*:]] | ||
; OPT-W32-NEXT: br i1 false, label %[[BB2:.*]], label %[[BB3:.*]] | ||
; OPT-W32: [[BB2]]: | ||
; OPT-W32-NEXT: br label %[[BB3]] | ||
; OPT-W32: [[BB3]]: | ||
; OPT-W32-NEXT: ret void | ||
; | ||
; OPT-W64-LABEL: define amdgpu_kernel void @fold_and_optimize_if_wavefrontsize( | ||
; OPT-W64-SAME: ptr addrspace(1) nocapture [[ARG:%.*]]) #[[ATTR0]] { | ||
; OPT-W64-NEXT: [[BB:.*:]] | ||
; OPT-W64-NEXT: br i1 true, label %[[BB2:.*]], label %[[BB3:.*]] | ||
; OPT-W64: [[BB2]]: | ||
; OPT-W64-NEXT: store i32 1, ptr addrspace(1) [[ARG]], align 4 | ||
; OPT-W64-NEXT: br label %[[BB3]] | ||
; OPT-W64: [[BB3]]: | ||
; OPT-W64-NEXT: ret void | ||
; | ||
bb: | ||
%tmp = tail call i32 @llvm.amdgcn.wavefrontsize() #0 | ||
%tmp1 = icmp ugt i32 %tmp, 32 | ||
br i1 %tmp1, label %bb2, label %bb3 | ||
|
||
bb2: ; preds = %bb | ||
store i32 1, ptr addrspace(1) %arg, align 4 | ||
br label %bb3 | ||
|
||
bb3: ; preds = %bb2, %bb | ||
ret void | ||
} | ||
|
||
declare i32 @llvm.amdgcn.wavefrontsize() #0 | ||
|
||
attributes #0 = { nounwind readnone speculatable } |
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.