Skip to content

[AMDGPU] New GFX11 v_cmp_tru_* aliases for integer comparisons #118976

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 1 commit into from
Dec 6, 2024

Conversation

jayfoad
Copy link
Contributor

@jayfoad jayfoad commented Dec 6, 2024

This is for compatibility with SP3. It only affects GFX11 because the
v_cmp_t_* instructions were removed in GFX12.

This is for compatibility with SP3. It only affects GFX11 because the
v_cmp_t_* instructions were removed in GFX12.
@llvmbot llvmbot added backend:AMDGPU mc Machine (object) code labels Dec 6, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 6, 2024

@llvm/pr-subscribers-backend-amdgpu

@llvm/pr-subscribers-mc

Author: Jay Foad (jayfoad)

Changes

This is for compatibility with SP3. It only affects GFX11 because the
v_cmp_t_* instructions were removed in GFX12.


Full diff: https://github.com/llvm/llvm-project/pull/118976.diff

3 Files Affected:

  • (modified) llvm/lib/Target/AMDGPU/VOPCInstructions.td (+11)
  • (added) llvm/test/MC/AMDGPU/gfx11_asm_vopc_alias.s (+14)
  • (added) llvm/test/MC/AMDGPU/gfx11_asm_vopcx_alias.s (+14)
diff --git a/llvm/lib/Target/AMDGPU/VOPCInstructions.td b/llvm/lib/Target/AMDGPU/VOPCInstructions.td
index 0a4b51c4ac631d..9bf043ea334fea 100644
--- a/llvm/lib/Target/AMDGPU/VOPCInstructions.td
+++ b/llvm/lib/Target/AMDGPU/VOPCInstructions.td
@@ -1956,6 +1956,17 @@ defm V_CMPX_CLASS_F16_fake16 : VOPCX_Real_t16_gfx11_gfx12<0x0fd, "v_cmpx_class_f
 defm V_CMPX_CLASS_F32     : VOPCX_Real_gfx11_gfx12<0x0fe>;
 defm V_CMPX_CLASS_F64     : VOPCX_Real_gfx11_gfx12<0x0ff>;
 
+let AssemblerPredicate = isGFX11Only in {
+  def : AMDGPUMnemonicAlias<"v_cmp_tru_i32", "v_cmp_t_i32">;
+  def : AMDGPUMnemonicAlias<"v_cmp_tru_u32", "v_cmp_t_u32">;
+  def : AMDGPUMnemonicAlias<"v_cmp_tru_i64", "v_cmp_t_i64">;
+  def : AMDGPUMnemonicAlias<"v_cmp_tru_u64", "v_cmp_t_u64">;
+  def : AMDGPUMnemonicAlias<"v_cmpx_tru_i32", "v_cmpx_t_i32">;
+  def : AMDGPUMnemonicAlias<"v_cmpx_tru_u32", "v_cmpx_t_u32">;
+  def : AMDGPUMnemonicAlias<"v_cmpx_tru_i64", "v_cmpx_t_i64">;
+  def : AMDGPUMnemonicAlias<"v_cmpx_tru_u64", "v_cmpx_t_u64">;
+}
+
 //===----------------------------------------------------------------------===//
 // GFX10.
 //===----------------------------------------------------------------------===//
diff --git a/llvm/test/MC/AMDGPU/gfx11_asm_vopc_alias.s b/llvm/test/MC/AMDGPU/gfx11_asm_vopc_alias.s
new file mode 100644
index 00000000000000..2b95e6a9487465
--- /dev/null
+++ b/llvm/test/MC/AMDGPU/gfx11_asm_vopc_alias.s
@@ -0,0 +1,14 @@
+// NOTE: Assertions have been autogenerated by utils/update_mc_test_checks.py UTC_ARGS: --version 5
+// RUN: llvm-mc -triple=amdgcn -mcpu=gfx1100 -mattr=+wavefrontsize64 -show-encoding %s | FileCheck -check-prefix=GFX11 %s
+
+v_cmp_tru_i32 vcc, v1, v2
+// GFX11: v_cmp_t_i32_e32 vcc, v1, v2             ; encoding: [0x01,0x05,0x8e,0x7c]
+
+v_cmp_tru_u32 vcc, v1, v2
+// GFX11: v_cmp_t_u32_e32 vcc, v1, v2             ; encoding: [0x01,0x05,0x9e,0x7c]
+
+v_cmp_tru_i64 vcc, v[1:2], v[2:3]
+// GFX11: v_cmp_t_i64_e32 vcc, v[1:2], v[2:3]     ; encoding: [0x01,0x05,0xae,0x7c]
+
+v_cmp_tru_u64 vcc, v[1:2], v[2:3]
+// GFX11: v_cmp_t_u64_e32 vcc, v[1:2], v[2:3]     ; encoding: [0x01,0x05,0xbe,0x7c]
diff --git a/llvm/test/MC/AMDGPU/gfx11_asm_vopcx_alias.s b/llvm/test/MC/AMDGPU/gfx11_asm_vopcx_alias.s
new file mode 100644
index 00000000000000..636ec3c19d70f1
--- /dev/null
+++ b/llvm/test/MC/AMDGPU/gfx11_asm_vopcx_alias.s
@@ -0,0 +1,14 @@
+// NOTE: Assertions have been autogenerated by utils/update_mc_test_checks.py UTC_ARGS: --version 5
+// RUN: llvm-mc -triple=amdgcn -mcpu=gfx1100 -mattr=+wavefrontsize64 -show-encoding %s | FileCheck -check-prefix=GFX11 %s
+
+v_cmpx_tru_i32 v1, v2
+// GFX11: v_cmpx_t_i32_e32 v1, v2                 ; encoding: [0x01,0x05,0x8e,0x7d]
+
+v_cmpx_tru_u32 v1, v2
+// GFX11: v_cmpx_t_u32_e32 v1, v2                 ; encoding: [0x01,0x05,0x9e,0x7d]
+
+v_cmpx_tru_i64 v[1:2], v[2:3]
+// GFX11: v_cmpx_t_i64_e32 v[1:2], v[2:3]         ; encoding: [0x01,0x05,0xae,0x7d]
+
+v_cmpx_tru_u64 v[1:2], v[2:3]
+// GFX11: v_cmpx_t_u64_e32 v[1:2], v[2:3]         ; encoding: [0x01,0x05,0xbe,0x7d]

@jayfoad jayfoad merged commit 33f4f39 into llvm:main Dec 6, 2024
9 of 10 checks passed
@jayfoad jayfoad deleted the v-cmp-tru branch December 6, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:AMDGPU mc Machine (object) code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants