[llvm] [AMDGPU] Add new aliases ds_subrev_u32/u64 for ds_rsub_u32/u64 (PR #83118)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 27 02:36:28 PST 2024


https://github.com/jayfoad updated https://github.com/llvm/llvm-project/pull/83118

>From daa50f732b4185f1796a515147434b8995a1877c Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Tue, 27 Feb 2024 10:04:17 +0000
Subject: [PATCH 1/2] [AMDGPU] Add new aliases ds_subrev_u32/u64 for
 ds_rsub_u32/u64

Note that the instructions have not been renamed and that there are no
corresponding aliases for ds_rsub_rtn_u32/u64. This matches SP3
behavior.
---
 llvm/lib/Target/AMDGPU/DSInstructions.td | 4 ++++
 llvm/test/MC/AMDGPU/gfx12_asm_ds_alias.s | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/llvm/lib/Target/AMDGPU/DSInstructions.td b/llvm/lib/Target/AMDGPU/DSInstructions.td
index 515b9476b25b75..074e13317ef89d 100644
--- a/llvm/lib/Target/AMDGPU/DSInstructions.td
+++ b/llvm/lib/Target/AMDGPU/DSInstructions.td
@@ -1259,6 +1259,10 @@ defm DS_PK_ADD_RTN_F16    : DS_Real_gfx12<0x0aa>;
 defm DS_PK_ADD_BF16       : DS_Real_gfx12<0x09b>;
 defm DS_PK_ADD_RTN_BF16   : DS_Real_gfx12<0x0ab>;
 
+// New aliases added in GFX12 without renaming the instructions.
+def : MnemonicAlias<"ds_subrev_u32", "ds_rsub_u32">, Requires<[isGFX12Plus]>;
+def : MnemonicAlias<"ds_subrev_u64", "ds_rsub_u64">, Requires<[isGFX12Plus]>;
+
 //===----------------------------------------------------------------------===//
 // GFX11.
 //===----------------------------------------------------------------------===//
diff --git a/llvm/test/MC/AMDGPU/gfx12_asm_ds_alias.s b/llvm/test/MC/AMDGPU/gfx12_asm_ds_alias.s
index aa4b028160175c..8b076094aa8581 100644
--- a/llvm/test/MC/AMDGPU/gfx12_asm_ds_alias.s
+++ b/llvm/test/MC/AMDGPU/gfx12_asm_ds_alias.s
@@ -23,3 +23,9 @@ ds_min_rtn_f32 v5, v1, v2
 
 ds_min_rtn_f64 v[5:6], v1, v[2:3]
 // GFX12: [0x00,0x00,0xc8,0xd9,0x01,0x02,0x00,0x05]
+
+ds_subrev_u32 v1, v2
+// GFX12: [0x00,0x00,0x08,0xd8,0x01,0x02,0x00,0x00]
+
+ds_subrev_u64 v1, v[2:3]
+// GFX12: [0x00,0x00,0x08,0xd9,0x01,0x02,0x00,0x00]

>From 9a5a0cdc748b268764f90a1543cc19a6a34917e9 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Tue, 27 Feb 2024 10:36:16 +0000
Subject: [PATCH 2/2] Check full output

---
 llvm/test/MC/AMDGPU/gfx12_asm_ds_alias.s | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/test/MC/AMDGPU/gfx12_asm_ds_alias.s b/llvm/test/MC/AMDGPU/gfx12_asm_ds_alias.s
index 8b076094aa8581..70767724840432 100644
--- a/llvm/test/MC/AMDGPU/gfx12_asm_ds_alias.s
+++ b/llvm/test/MC/AMDGPU/gfx12_asm_ds_alias.s
@@ -25,7 +25,7 @@ ds_min_rtn_f64 v[5:6], v1, v[2:3]
 // GFX12: [0x00,0x00,0xc8,0xd9,0x01,0x02,0x00,0x05]
 
 ds_subrev_u32 v1, v2
-// GFX12: [0x00,0x00,0x08,0xd8,0x01,0x02,0x00,0x00]
+// GFX12: ds_rsub_u32 v1, v2                      ; encoding: [0x00,0x00,0x08,0xd8,0x01,0x02,0x00,0x00]
 
 ds_subrev_u64 v1, v[2:3]
-// GFX12: [0x00,0x00,0x08,0xd9,0x01,0x02,0x00,0x00]
+// GFX12: ds_rsub_u64 v1, v[2:3]                  ; encoding: [0x00,0x00,0x08,0xd9,0x01,0x02,0x00,0x00]



More information about the llvm-commits mailing list