-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[AMDGPU] Recognise bitmask operations as srcmods on select #152119
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
chrisjbris
merged 8 commits into
llvm:main
from
chrisjbris:chrisjbris/integer_select_source_modifiers_VOP
Aug 7, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2ece2eb
[AMDGPU] Recognise bitmask operations as srcmods on select
chrisjbris 0b9cd67
Tidy up comment.
chrisjbris f8329c1
Corrections based on review comments.
chrisjbris 89ff393
Add negative test for canonicalizing instructions. This test contains…
chrisjbris a42040f
Add additional scalar test cases for completeness, even though srcmods
chrisjbris aa31e45
Remove v2i32 condition for now.
chrisjbris 529950f
Revert method of obtaining constant
chrisjbris 2d4bf68
Remove superfluous parantheses.
chrisjbris 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
93 changes: 93 additions & 0 deletions
93
llvm/test/CodeGen/AMDGPU/integer-canonicalizing-src-modifiers.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 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx700 < %s | FileCheck -check-prefixes=GCN,GFX7 %s | ||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 < %s | FileCheck -check-prefixes=GCN,GFX9 %s | ||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -mattr=+real-true16 < %s | FileCheck -check-prefixes=GFX11,GFX11-TRUE16 %s | ||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -mattr=-real-true16 < %s | FileCheck -check-prefixes=GFX11,GFX11-FAKE16 %s | ||
chrisjbris marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
; Demonstrate that the conversion of bitmasks affecting the sign bit on integers to srcmods | ||
; does not apply to canonicalizing instructions. | ||
|
||
define double @v_uitofp_i32_to_f64_abs(i32 %arg0) nounwind { | ||
; GCN-LABEL: v_uitofp_i32_to_f64_abs: | ||
; GCN: ; %bb.0: | ||
; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
; GCN-NEXT: v_and_b32_e32 v0, 0x7fffffff, v0 | ||
; GCN-NEXT: v_cvt_f64_u32_e32 v[0:1], v0 | ||
; GCN-NEXT: s_setpc_b64 s[30:31] | ||
; | ||
; GFX11-LABEL: v_uitofp_i32_to_f64_abs: | ||
; GFX11: ; %bb.0: | ||
; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
; GFX11-NEXT: v_and_b32_e32 v0, 0x7fffffff, v0 | ||
; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1) | ||
; GFX11-NEXT: v_cvt_f64_u32_e32 v[0:1], v0 | ||
; GFX11-NEXT: s_setpc_b64 s[30:31] | ||
%arg0.abs = and i32 %arg0, u0x7fffffff | ||
%cvt = uitofp i32 %arg0.abs to double | ||
ret double %cvt | ||
} | ||
|
||
define double @v_uitofp_i32_to_f64_neg(i32 %arg0) nounwind { | ||
; GCN-LABEL: v_uitofp_i32_to_f64_neg: | ||
; GCN: ; %bb.0: | ||
; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
; GCN-NEXT: v_and_b32_e32 v0, 0x80000000, v0 | ||
; GCN-NEXT: v_cvt_f64_u32_e32 v[0:1], v0 | ||
; GCN-NEXT: s_setpc_b64 s[30:31] | ||
; | ||
; GFX11-LABEL: v_uitofp_i32_to_f64_neg: | ||
; GFX11: ; %bb.0: | ||
; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
; GFX11-NEXT: v_and_b32_e32 v0, 0x80000000, v0 | ||
; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1) | ||
; GFX11-NEXT: v_cvt_f64_u32_e32 v[0:1], v0 | ||
; GFX11-NEXT: s_setpc_b64 s[30:31] | ||
%arg0.neg = and i32 %arg0, u0x80000000 | ||
%cvt = uitofp i32 %arg0.neg to double | ||
ret double %cvt | ||
} | ||
|
||
define double @s_uitofp_i32_to_f64_abs(i32 inreg %arg0) nounwind { | ||
; GCN-LABEL: s_uitofp_i32_to_f64_abs: | ||
; GCN: ; %bb.0: | ||
; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
; GCN-NEXT: s_bitset0_b32 s16, 31 | ||
; GCN-NEXT: v_cvt_f64_u32_e32 v[0:1], s16 | ||
; GCN-NEXT: s_setpc_b64 s[30:31] | ||
; | ||
; GFX11-LABEL: s_uitofp_i32_to_f64_abs: | ||
; GFX11: ; %bb.0: | ||
; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
; GFX11-NEXT: s_bitset0_b32 s0, 31 | ||
; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | ||
; GFX11-NEXT: v_cvt_f64_u32_e32 v[0:1], s0 | ||
; GFX11-NEXT: s_setpc_b64 s[30:31] | ||
%arg0.abs = and i32 %arg0, u0x7fffffff | ||
%cvt = uitofp i32 %arg0.abs to double | ||
ret double %cvt | ||
} | ||
|
||
define double @s_uitofp_i32_to_f64_neg(i32 inreg %arg0) nounwind { | ||
; GCN-LABEL: s_uitofp_i32_to_f64_neg: | ||
; GCN: ; %bb.0: | ||
; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
; GCN-NEXT: s_and_b32 s4, s16, 0x80000000 | ||
; GCN-NEXT: v_cvt_f64_u32_e32 v[0:1], s4 | ||
; GCN-NEXT: s_setpc_b64 s[30:31] | ||
; | ||
; GFX11-LABEL: s_uitofp_i32_to_f64_neg: | ||
; GFX11: ; %bb.0: | ||
; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
; GFX11-NEXT: s_and_b32 s0, s0, 0x80000000 | ||
; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | ||
; GFX11-NEXT: v_cvt_f64_u32_e32 v[0:1], s0 | ||
; GFX11-NEXT: s_setpc_b64 s[30:31] | ||
%arg0.neg = and i32 %arg0, u0x80000000 | ||
%cvt = uitofp i32 %arg0.neg to double | ||
ret double %cvt | ||
} | ||
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: | ||
; GFX11-FAKE16: {{.*}} | ||
; GFX11-TRUE16: {{.*}} | ||
; GFX7: {{.*}} | ||
; GFX9: {{.*}} |
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.
Uh oh!
There was an error while loading. Please reload this page.