[PATCH] D133972: [AMDGPU] Fix size of SOPK instructions to 4 bytes

Anshil Gandhi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 20 11:48:41 PDT 2022


gandhi21299 updated this revision to Diff 461643.
gandhi21299 added a comment.

- Simplified sopk-no-literal.ll test. This test checks for the size of the kernel which should be 28 bytes as each instruction is 4 bytes long, except for s_load_b32 which is 8 bytes in size.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133972/new/

https://reviews.llvm.org/D133972

Files:
  llvm/lib/Target/AMDGPU/SOPInstructions.td
  llvm/test/CodeGen/AMDGPU/sopk-no-literal.ll


Index: llvm/test/CodeGen/AMDGPU/sopk-no-literal.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/sopk-no-literal.ll
@@ -0,0 +1,24 @@
+; REQUIRES: asserts
+; RUN: llc -O0 -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -debug-only=branch-relaxation -verify-machineinstrs < %s 2>&1 | FileCheck --check-prefix=GFX10 %s
+
+; GFX10: Basic blocks after relaxation
+; GFX10: %bb.0	offset=00000000	size=0x1c
+
+; Each instruction in the following kernel is 4 bytes in size,
+; except s_load_b32 which is 8 bytes in size. Hence, 0x1c bytes in total.
+define amdgpu_kernel void @test_sopk_size(i32 %var.mode) {
+; GFX10-LABEL: test_sopk_size:
+; GFX10:  ; %bb.0:
+; GFX10:    s_load_b32 s0, s[0:1], 0x0
+; GFX10:    s_mov_b32 s1, 3
+; GFX10:    s_setreg_b32 hwreg(HW_REG_MODE, 0, 2), s1
+; GFX10:    s_waitcnt lgkmcnt(0)
+; GFX10:    s_setreg_b32 hwreg(HW_REG_MODE, 0, 3), s0
+; GFX10:    s_endpgm
+  call void @llvm.amdgcn.s.setreg(i32 2049, i32 3)
+  call void @llvm.amdgcn.s.setreg(i32 4097, i32 %var.mode)
+  call void asm sideeffect "", ""()
+  ret void
+}
+
+declare void @llvm.amdgcn.s.setreg(i32 immarg, i32)
\ No newline at end of file
Index: llvm/lib/Target/AMDGPU/SOPInstructions.td
===================================================================
--- llvm/lib/Target/AMDGPU/SOPInstructions.td
+++ llvm/lib/Target/AMDGPU/SOPInstructions.td
@@ -722,6 +722,7 @@
   let hasSideEffects = 0;
   let SALU = 1;
   let SOPK = 1;
+  let FixedSize = 1;
   let SchedRW = [WriteSALU];
   let UseNamedOperandTable = 1;
   string Mnemonic = opName;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133972.461643.patch
Type: text/x-patch
Size: 1597 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220920/b83118d9/attachment.bin>


More information about the llvm-commits mailing list