2019-05-14 03:30:06 +08:00
|
|
|
;RUN: llc -march=amdgcn -mcpu=verde -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=SI -check-prefix=SIVI %s
|
|
|
|
;RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=VIPLUS -check-prefix=SIVI %s
|
|
|
|
;RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=VIPLUS -check-prefix=GFX9 %s
|
2017-02-16 06:17:09 +08:00
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}test_interrupt:
|
|
|
|
; GCN: s_mov_b32 m0, 0
|
|
|
|
; GCN-NOT: s_mov_b32 m0
|
|
|
|
; GCN: s_sendmsg sendmsg(MSG_INTERRUPT)
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_interrupt() {
|
2017-02-16 06:17:09 +08:00
|
|
|
body:
|
|
|
|
call void @llvm.amdgcn.s.sendmsg(i32 1, i32 0);
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}test_gs_emit:
|
|
|
|
; GCN: s_mov_b32 m0, 0
|
|
|
|
; GCN-NOT: s_mov_b32 m0
|
|
|
|
; GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT, 0)
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_gs_emit() {
|
2017-02-16 06:17:09 +08:00
|
|
|
body:
|
|
|
|
call void @llvm.amdgcn.s.sendmsg(i32 34, i32 0);
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}test_gs_cut:
|
|
|
|
; GCN: s_mov_b32 m0, 0
|
|
|
|
; GCN-NOT: s_mov_b32 m0
|
|
|
|
; GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 1)
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_gs_cut() {
|
2017-02-16 06:17:09 +08:00
|
|
|
body:
|
|
|
|
call void @llvm.amdgcn.s.sendmsg(i32 274, i32 0);
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}test_gs_emit_cut:
|
|
|
|
; GCN: s_mov_b32 m0, 0
|
|
|
|
; GCN-NOT: s_mov_b32 m0
|
|
|
|
; GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2)
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_gs_emit_cut() {
|
2017-02-16 06:17:09 +08:00
|
|
|
body:
|
|
|
|
call void @llvm.amdgcn.s.sendmsg(i32 562, i32 0)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}test_gs_done:
|
|
|
|
; GCN: s_mov_b32 m0, 0
|
|
|
|
; GCN-NOT: s_mov_b32 m0
|
|
|
|
; GCN: s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP)
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_gs_done() {
|
2017-02-16 06:17:09 +08:00
|
|
|
body:
|
|
|
|
call void @llvm.amdgcn.s.sendmsg(i32 3, i32 0)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2019-05-14 03:30:06 +08:00
|
|
|
; GCN-LABEL: {{^}}test_gs_alloc_req:
|
|
|
|
; GCN: s_mov_b32 m0, s0
|
|
|
|
; GCN-NOT: s_mov_b32 m0
|
|
|
|
; VIPLUS-NEXT: s_nop 0
|
2019-06-28 22:14:02 +08:00
|
|
|
; SIVI: s_sendmsg sendmsg(9, 0, 0)
|
2019-05-14 03:30:06 +08:00
|
|
|
; GFX9: s_sendmsg sendmsg(MSG_GS_ALLOC_REQ)
|
|
|
|
define amdgpu_kernel void @test_gs_alloc_req(i32 inreg %a) {
|
|
|
|
body:
|
|
|
|
call void @llvm.amdgcn.s.sendmsg(i32 9, i32 %a)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-16 06:17:09 +08:00
|
|
|
; GCN-LABEL: {{^}}sendmsg:
|
|
|
|
; GCN: s_mov_b32 m0, s0
|
2019-05-14 03:30:06 +08:00
|
|
|
; VIPLUS-NEXT: s_nop 0
|
2017-02-16 06:17:09 +08:00
|
|
|
; GCN-NEXT: sendmsg(MSG_GS_DONE, GS_OP_NOP)
|
|
|
|
; GCN-NEXT: s_endpgm
|
|
|
|
define amdgpu_gs void @sendmsg(i32 inreg %a) #0 {
|
|
|
|
call void @llvm.amdgcn.s.sendmsg(i32 3, i32 %a)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}sendmsghalt:
|
|
|
|
; GCN: s_mov_b32 m0, s0
|
2019-05-14 03:30:06 +08:00
|
|
|
; VIPLUS-NEXT: s_nop 0
|
2017-02-16 06:17:09 +08:00
|
|
|
; GCN-NEXT: s_sendmsghalt sendmsg(MSG_INTERRUPT)
|
|
|
|
; GCN-NEXT: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @sendmsghalt(i32 inreg %a) #0 {
|
2017-02-16 06:17:09 +08:00
|
|
|
call void @llvm.amdgcn.s.sendmsghalt(i32 1, i32 %a)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}test_interrupt_halt:
|
|
|
|
; GCN: s_mov_b32 m0, 0
|
|
|
|
; GCN-NOT: s_mov_b32 m0
|
|
|
|
; GCN: s_sendmsghalt sendmsg(MSG_INTERRUPT)
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_interrupt_halt() {
|
2017-02-16 06:17:09 +08:00
|
|
|
body:
|
|
|
|
call void @llvm.amdgcn.s.sendmsghalt(i32 1, i32 0)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}test_gs_emit_halt:
|
|
|
|
; GCN: s_mov_b32 m0, 0
|
|
|
|
; GCN-NOT: s_mov_b32 m0
|
|
|
|
; GCN: s_sendmsghalt sendmsg(MSG_GS, GS_OP_EMIT, 0)
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_gs_emit_halt() {
|
2017-02-16 06:17:09 +08:00
|
|
|
body:
|
|
|
|
call void @llvm.amdgcn.s.sendmsghalt(i32 34, i32 0)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}test_gs_cut_halt:
|
|
|
|
; GCN: s_mov_b32 m0, 0
|
|
|
|
; GCN-NOT: s_mov_b32 m0
|
|
|
|
; GCN: s_sendmsghalt sendmsg(MSG_GS, GS_OP_CUT, 1)
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_gs_cut_halt() {
|
2017-02-16 06:17:09 +08:00
|
|
|
body:
|
|
|
|
call void @llvm.amdgcn.s.sendmsghalt(i32 274, i32 0)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}test_gs_emit_cut_halt:
|
|
|
|
; GCN: s_mov_b32 m0, 0
|
|
|
|
; GCN-NOT: s_mov_b32 m0
|
|
|
|
; GCN: s_sendmsghalt sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2)
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_gs_emit_cut_halt() {
|
2017-02-16 06:17:09 +08:00
|
|
|
body:
|
|
|
|
call void @llvm.amdgcn.s.sendmsghalt(i32 562, i32 0)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}test_gs_done_halt:
|
|
|
|
; GCN: s_mov_b32 m0, 0
|
|
|
|
; GCN-NOT: s_mov_b32 m0
|
|
|
|
; GCN: s_sendmsghalt sendmsg(MSG_GS_DONE, GS_OP_NOP)
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_gs_done_halt() {
|
2017-02-16 06:17:09 +08:00
|
|
|
body:
|
|
|
|
call void @llvm.amdgcn.s.sendmsghalt(i32 3, i32 0)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2018-04-20 15:14:25 +08:00
|
|
|
; TODO: This should use s_mul_i32 instead of v_mul_u32_u24 + v_readfirstlane!
|
|
|
|
;
|
|
|
|
; GCN-LABEL: {{^}}test_mul24:
|
|
|
|
; GCN: v_mul_u32_u24_e32
|
|
|
|
; GCN: v_readfirstlane_b32
|
|
|
|
; GCN: s_mov_b32 m0,
|
|
|
|
; GCN: s_sendmsg sendmsg(MSG_INTERRUPT)
|
|
|
|
define amdgpu_gs void @test_mul24(i32 inreg %arg) {
|
|
|
|
body:
|
|
|
|
%tmp1 = and i32 %arg, 511
|
|
|
|
%tmp2 = mul nuw nsw i32 %tmp1, 12288
|
|
|
|
call void @llvm.amdgcn.s.sendmsg(i32 1, i32 %tmp2)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
AMDGPU: Force skip over s_sendmsg and exp instructions
Summary:
These instructions interact with hardware blocks outside the shader core,
and they can have "scalar" side effects even when EXEC = 0. We don't
want these scalar side effects to occur when all lanes want to skip
these instructions, so always add the execz skip branch instruction
for basic blocks that contain them.
Also ensure that we skip scalar stores / atomics, though we don't
code-gen those yet.
Reviewers: arsenm, rampitec
Subscribers: kzhuravl, wdng, yaxunl, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D48431
Change-Id: Ieaeb58352e2789ffd64745603c14970c60819d44
llvm-svn: 338235
2018-07-30 17:23:59 +08:00
|
|
|
; GCN-LABEL: {{^}}if_sendmsg:
|
|
|
|
; GCN: s_cbranch_execz
|
|
|
|
; GCN: s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP)
|
|
|
|
define amdgpu_gs void @if_sendmsg(i32 %flag) #0 {
|
|
|
|
%cc = icmp eq i32 %flag, 0
|
|
|
|
br i1 %cc, label %sendmsg, label %end
|
|
|
|
|
|
|
|
sendmsg:
|
|
|
|
call void @llvm.amdgcn.s.sendmsg(i32 3, i32 0)
|
|
|
|
br label %end
|
|
|
|
|
|
|
|
end:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-16 06:17:09 +08:00
|
|
|
declare void @llvm.amdgcn.s.sendmsg(i32, i32) #0
|
|
|
|
declare void @llvm.amdgcn.s.sendmsghalt(i32, i32) #0
|
|
|
|
|
|
|
|
attributes #0 = { nounwind }
|