-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AMDGPU] Prevent folding of the negative i32 literals as i64 #70274
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
5 commits
Select commit
Hold shift + click to select a range
b73fbe5
[AMDGPU] Prevent folding of the negative i32 literals as i64
rampitec 9eaa267
Fold common condition in checks.
rampitec 71e5a19
Added more tests, positive and negative
rampitec 073baf8
Removed isInt<32>() check and added tests
rampitec db086eb
Simplified condition.
rampitec 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 3 | ||
# RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs -run-pass=si-fold-operands -o - %s | FileCheck -check-prefix=GCN %s | ||
|
||
# The constant is 0xffffffff80000000. It is 64-bit negative constant, but it passes the test | ||
# isInt<32>(). Nonetheless it is not a legal literal for a binary or unsigned operand and | ||
# cannot be used right in the shift as HW will zero extend it. | ||
|
||
--- | ||
name: imm64_shift_int32_const_0xffffffff80000000 | ||
body: | | ||
bb.0: | ||
; GCN-LABEL: name: imm64_shift_int32_const_0xffffffff80000000 | ||
; GCN: [[S_MOV_B:%[0-9]+]]:sreg_64 = S_MOV_B64_IMM_PSEUDO -2147483648 | ||
; GCN-NEXT: [[S_LSHL_B64_:%[0-9]+]]:sreg_64 = S_LSHL_B64 [[S_MOV_B]], 1, implicit-def $scc | ||
; GCN-NEXT: S_ENDPGM 0, implicit [[S_LSHL_B64_]] | ||
%0:sreg_64 = S_MOV_B64_IMM_PSEUDO 18446744071562067968 | ||
%1:sreg_64 = S_LSHL_B64 %0, 1, implicit-def $scc | ||
S_ENDPGM 0, implicit %1 | ||
|
||
... | ||
|
||
--- | ||
name: imm64_shift_int32_const_0xffffffff | ||
body: | | ||
bb.0: | ||
; GCN-LABEL: name: imm64_shift_int32_const_0xffffffff | ||
; GCN: [[S_MOV_B:%[0-9]+]]:sreg_64 = S_MOV_B64_IMM_PSEUDO 4294967295 | ||
; GCN-NEXT: [[S_LSHL_B64_:%[0-9]+]]:sreg_64 = S_LSHL_B64 [[S_MOV_B]], 1, implicit-def $scc | ||
; GCN-NEXT: S_ENDPGM 0, implicit [[S_LSHL_B64_]] | ||
%0:sreg_64 = S_MOV_B64_IMM_PSEUDO 4294967295 | ||
%1:sreg_64 = S_LSHL_B64 %0, 1, implicit-def $scc | ||
S_ENDPGM 0, implicit %1 | ||
|
||
... | ||
|
||
--- | ||
name: imm64_shift_int32_const_0x80000000 | ||
body: | | ||
bb.0: | ||
; GCN-LABEL: name: imm64_shift_int32_const_0x80000000 | ||
; GCN: [[S_MOV_B:%[0-9]+]]:sreg_64 = S_MOV_B64_IMM_PSEUDO 2147483648 | ||
; GCN-NEXT: [[S_LSHL_B64_:%[0-9]+]]:sreg_64 = S_LSHL_B64 [[S_MOV_B]], 1, implicit-def $scc | ||
; GCN-NEXT: S_ENDPGM 0, implicit [[S_LSHL_B64_]] | ||
%0:sreg_64 = S_MOV_B64_IMM_PSEUDO 2147483648 | ||
%1:sreg_64 = S_LSHL_B64 %0, 1, implicit-def $scc | ||
S_ENDPGM 0, implicit %1 | ||
|
||
... | ||
|
||
--- | ||
name: imm64_shift_int32_const_0x7fffffff | ||
body: | | ||
bb.0: | ||
; GCN-LABEL: name: imm64_shift_int32_const_0x7fffffff | ||
; GCN: [[S_LSHL_B64_:%[0-9]+]]:sreg_64 = S_LSHL_B64 2147483647, 1, implicit-def $scc | ||
; GCN-NEXT: S_ENDPGM 0, implicit [[S_LSHL_B64_]] | ||
%0:sreg_64 = S_MOV_B64_IMM_PSEUDO 2147483647 | ||
%1:sreg_64 = S_LSHL_B64 %0, 1, implicit-def $scc | ||
S_ENDPGM 0, implicit %1 | ||
|
||
... | ||
|
||
--- | ||
name: imm64_shift_int32_const_0x1ffffffff | ||
body: | | ||
bb.0: | ||
; GCN-LABEL: name: imm64_shift_int32_const_0x1ffffffff | ||
; GCN: [[S_MOV_B:%[0-9]+]]:sreg_64 = S_MOV_B64_IMM_PSEUDO 8589934591 | ||
; GCN-NEXT: [[S_LSHL_B64_:%[0-9]+]]:sreg_64 = S_LSHL_B64 [[S_MOV_B]], 1, implicit-def $scc | ||
; GCN-NEXT: S_ENDPGM 0, implicit [[S_LSHL_B64_]] | ||
%0:sreg_64 = S_MOV_B64_IMM_PSEUDO 8589934591 | ||
%1:sreg_64 = S_LSHL_B64 %0, 1, implicit-def $scc | ||
S_ENDPGM 0, implicit %1 | ||
|
||
... | ||
|
||
--- | ||
name: imm64_shift_int32_const_0xffffffffffffffff | ||
body: | | ||
bb.0: | ||
; GCN-LABEL: name: imm64_shift_int32_const_0xffffffffffffffff | ||
; GCN: [[S_LSHL_B64_:%[0-9]+]]:sreg_64 = S_LSHL_B64 -1, 1, implicit-def $scc | ||
; GCN-NEXT: S_ENDPGM 0, implicit [[S_LSHL_B64_]] | ||
%0:sreg_64 = S_MOV_B64_IMM_PSEUDO -1 | ||
%1:sreg_64 = S_LSHL_B64 %0, 1, implicit-def $scc | ||
S_ENDPGM 0, implicit %1 | ||
|
||
... | ||
|
||
--- | ||
name: imm64_ashr_int32_const_0xffffffff | ||
body: | | ||
bb.0: | ||
; GCN-LABEL: name: imm64_ashr_int32_const_0xffffffff | ||
; GCN: [[S_MOV_B:%[0-9]+]]:sreg_64 = S_MOV_B64_IMM_PSEUDO 4294967295 | ||
; GCN-NEXT: [[S_ASHR_I64_:%[0-9]+]]:sreg_64 = S_ASHR_I64 [[S_MOV_B]], 1, implicit-def $scc | ||
; GCN-NEXT: S_ENDPGM 0, implicit [[S_ASHR_I64_]] | ||
%0:sreg_64 = S_MOV_B64_IMM_PSEUDO 4294967295 | ||
%1:sreg_64 = S_ASHR_I64 %0, 1, implicit-def $scc | ||
S_ENDPGM 0, implicit %1 | ||
|
||
... | ||
|
||
--- | ||
name: imm64_ashr_int32_const_0x7fffffff | ||
body: | | ||
bb.0: | ||
; GCN-LABEL: name: imm64_ashr_int32_const_0x7fffffff | ||
; GCN: [[S_ASHR_I64_:%[0-9]+]]:sreg_64 = S_ASHR_I64 2147483647, 1, implicit-def $scc | ||
; GCN-NEXT: S_ENDPGM 0, implicit [[S_ASHR_I64_]] | ||
%0:sreg_64 = S_MOV_B64_IMM_PSEUDO 2147483647 | ||
%1:sreg_64 = S_ASHR_I64 %0, 1, implicit-def $scc | ||
S_ENDPGM 0, implicit %1 | ||
|
||
... | ||
|
||
--- | ||
name: imm64_ashr_int32_const_0xffffffffffffffff | ||
body: | | ||
bb.0: | ||
; GCN-LABEL: name: imm64_ashr_int32_const_0xffffffffffffffff | ||
; GCN: [[S_ASHR_I64_:%[0-9]+]]:sreg_64 = S_ASHR_I64 -1, 1, implicit-def $scc | ||
; GCN-NEXT: S_ENDPGM 0, implicit [[S_ASHR_I64_]] | ||
%0:sreg_64 = S_MOV_B64_IMM_PSEUDO -1 | ||
%1:sreg_64 = S_ASHR_I64 %0, 1, implicit-def $scc | ||
S_ENDPGM 0, implicit %1 | ||
|
||
... |
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.