-
Notifications
You must be signed in to change notification settings - Fork 13.6k
AMDGPU: Cleanup immediate selection patterns #100787
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
arsenm
merged 1 commit into
main
from
users/arsenm/amdgpu-tablegen-immediate-pattern-cleanup
Jul 30, 2024
Merged
AMDGPU: Cleanup immediate selection patterns #100787
arsenm
merged 1 commit into
main
from
users/arsenm/amdgpu-tablegen-immediate-pattern-cleanup
Jul 30, 2024
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
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced Jul 26, 2024
@llvm/pr-subscribers-backend-amdgpu @llvm/pr-subscribers-llvm-globalisel Author: Matt Arsenault (arsenm) ChangesReorder for consistency, so the same types for v/s are together. Full diff: https://github.com/llvm/llvm-project/pull/100787.diff 1 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/SIInstructions.td b/llvm/lib/Target/AMDGPU/SIInstructions.td
index d2101654d2acb..bcf778b31d276 100644
--- a/llvm/lib/Target/AMDGPU/SIInstructions.td
+++ b/llvm/lib/Target/AMDGPU/SIInstructions.td
@@ -2138,19 +2138,26 @@ def : GCNPat <
/********** Immediate Patterns **********/
/********** ================== **********/
+// FIXME: Remove VGPRImm. Should be inferrable from register bank.
+
def : GCNPat <
(VGPRImm<(i32 imm)>:$imm),
(V_MOV_B32_e32 imm:$imm)
>;
def : GCNPat <
- (VGPRImm<(f32 fpimm)>:$imm),
- (V_MOV_B32_e32 (f32 (bitcast_fpimm_to_i32 $imm)))
+ (i32 imm:$imm),
+ (S_MOV_B32 imm:$imm)
>;
def : GCNPat <
- (i32 imm:$imm),
- (S_MOV_B32 imm:$imm)
+ (p5 frameindex:$fi),
+ (V_MOV_B32_e32 (p5 (frameindex_to_targetframeindex $fi)))
+>;
+
+def : GCNPat <
+ (p5 frameindex:$fi),
+ (S_MOV_B32 (p5 (frameindex_to_targetframeindex $fi)))
>;
def : GCNPat <
@@ -2168,40 +2175,34 @@ def : GCNPat <
(V_MOV_B32_e32 imm:$imm)
>;
-// FIXME: Workaround for ordering issue with peephole optimizer where
-// a register class copy interferes with immediate folding. Should
-// use s_mov_b32, which can be shrunk to s_movk_i32
def : GCNPat <
- (VGPRImm<(f16 fpimm)>:$imm),
- (V_MOV_B32_e32 (f16 (bitcast_fpimm_to_i32 $imm)))
+ (i16 imm:$imm),
+ (S_MOV_B32 imm:$imm)
>;
def : GCNPat <
- (VGPRImm<(bf16 fpimm)>:$imm),
- (V_MOV_B32_e32 (bf16 (bitcast_fpimm_to_i32 $imm)))
+ (VGPRImm<(f16 fpimm)>:$imm),
+ (V_MOV_B32_e32 (f16 (bitcast_fpimm_to_i32 $imm)))
>;
-// V_MOV_B64_PSEUDO and S_MOV_B64_IMM_PSEUDO can be used with any 64-bit
-// immediate and wil be expanded as needed, but we will only use these patterns
-// for values which can be encoded.
def : GCNPat <
- (VGPRImm<(i64 imm)>:$imm),
- (V_MOV_B64_PSEUDO imm:$imm)
+ (f16 fpimm:$imm),
+ (S_MOV_B32 (i32 (bitcast_fpimm_to_i32 $imm)))
>;
def : GCNPat <
- (VGPRImm<(f64 fpimm)>:$imm),
- (V_MOV_B64_PSEUDO (f64 (bitcast_fpimm_to_i64 $imm)))
+ (VGPRImm<(bf16 fpimm)>:$imm),
+ (V_MOV_B32_e32 (bf16 (bitcast_fpimm_to_i32 $imm)))
>;
def : GCNPat <
- (i64 imm:$imm),
- (S_MOV_B64_IMM_PSEUDO imm:$imm)
+ (bf16 fpimm:$imm),
+ (S_MOV_B32 (i32 (bitcast_fpimm_to_i32 $imm)))
>;
def : GCNPat <
- (f64 fpimm:$imm),
- (S_MOV_B64_IMM_PSEUDO (i64 (bitcast_fpimm_to_i64 fpimm:$imm)))
+ (VGPRImm<(f32 fpimm)>:$imm),
+ (V_MOV_B32_e32 (f32 (bitcast_fpimm_to_i32 $imm)))
>;
def : GCNPat <
@@ -2210,31 +2211,38 @@ def : GCNPat <
>;
def : GCNPat <
- (f16 fpimm:$imm),
- (S_MOV_B32 (i32 (bitcast_fpimm_to_i32 $imm)))
+ (VGPRImm<(i64 imm)>:$imm),
+ (V_MOV_B64_PSEUDO imm:$imm)
>;
def : GCNPat <
- (bf16 fpimm:$imm),
- (S_MOV_B32 (i32 (bitcast_fpimm_to_i32 $imm)))
+ (i64 InlineImm64:$imm),
+ (S_MOV_B64 InlineImm64:$imm)
>;
def : GCNPat <
- (p5 frameindex:$fi),
- (V_MOV_B32_e32 (p5 (frameindex_to_targetframeindex $fi)))
+ (i64 imm:$imm),
+ (S_MOV_B64_IMM_PSEUDO imm:$imm)
>;
def : GCNPat <
- (p5 frameindex:$fi),
- (S_MOV_B32 (p5 (frameindex_to_targetframeindex $fi)))
+ (VGPRImm<(f64 fpimm)>:$imm),
+ (V_MOV_B64_PSEUDO (f64 (bitcast_fpimm_to_i64 $imm)))
>;
+// V_MOV_B64_PSEUDO and S_MOV_B64_IMM_PSEUDO can be used with any 64-bit
+// immediate and wil be expanded as needed, but we will only use these patterns
+// for values which can be encoded.
def : GCNPat <
- (i64 InlineImm64:$imm),
- (S_MOV_B64 InlineImm64:$imm)
+ (f64 InlineImmFP64:$imm),
+ (S_MOV_B64 (i64 (bitcast_fpimm_to_i64 $imm)))
+>;
+
+def : GCNPat <
+ (f64 fpimm:$imm),
+ (S_MOV_B64_IMM_PSEUDO (i64 (bitcast_fpimm_to_i64 fpimm:$imm)))
>;
-// Set to sign-extended 64-bit value (true = -1, false = 0)
// Set to sign-extended 64-bit value (true = -1, false = 0)
def : GCNPat <(i1 imm:$imm),
(S_MOV_B64 imm:$imm)> {
@@ -2246,11 +2254,6 @@ def : GCNPat <(i1 imm:$imm),
let WaveSizePredicate = isWave32;
}
-def : GCNPat <
- (f64 InlineImmFP64:$imm),
- (S_MOV_B64 (f64 (bitcast_fpimm_to_i64 InlineImmFP64:$imm)))
->;
-
/********** ================== **********/
/********** Intrinsic Patterns **********/
/********** ================== **********/
|
Sisyph
approved these changes
Jul 29, 2024
4a7ffeb
to
1e492ae
Compare
794f20e
to
51e2ac2
Compare
1e492ae
to
8104287
Compare
Base automatically changed from
users/arsenm/amdgpu-globalisel-partially-move-constant-selection-to-patterns
to
main
July 30, 2024 14:18
Reorder for consistency, so the same types for v/s are together.
51e2ac2
to
35d35e4
Compare
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.
Reorder for consistency, so the same types for v/s are together.