1 ; RUN: llc -march=amdgcn -mcpu=fiji -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=VI %s
3 declare half @llvm.amdgcn.div.fixup.f16(half %a, half %b, half %c)
5 ; GCN-LABEL: {{^}}div_fixup_f16
6 ; GCN: buffer_load_ushort v[[A_F16:[0-9]+]]
7 ; GCN: buffer_load_ushort v[[B_F16:[0-9]+]]
8 ; GCN: buffer_load_ushort v[[C_F16:[0-9]+]]
9 ; VI: v_div_fixup_f16 v[[R_F16:[0-9]+]], v[[A_F16]], v[[B_F16]], v[[C_F16]]
10 ; GCN: buffer_store_short v[[R_F16]]
12 define amdgpu_kernel void @div_fixup_f16(
13 half addrspace(1)* %r,
14 half addrspace(1)* %a,
15 half addrspace(1)* %b,
16 half addrspace(1)* %c) {
18 %a.val = load volatile half, half addrspace(1)* %a
19 %b.val = load volatile half, half addrspace(1)* %b
20 %c.val = load volatile half, half addrspace(1)* %c
21 %r.val = call half @llvm.amdgcn.div.fixup.f16(half %a.val, half %b.val, half %c.val)
22 store half %r.val, half addrspace(1)* %r
26 ; GCN-LABEL: {{^}}div_fixup_f16_imm_a
27 ; GCN: buffer_load_ushort v[[B_F16:[0-9]+]]
28 ; GCN: buffer_load_ushort v[[C_F16:[0-9]+]]
29 ; VI: s_movk_i32 s[[A_F16:[0-9]+]], 0x4200{{$}}
30 ; VI: v_div_fixup_f16 v[[R_F16:[0-9]+]], s[[A_F16]], v[[B_F16]], v[[C_F16]]
31 ; GCN: buffer_store_short v[[R_F16]]
33 define amdgpu_kernel void @div_fixup_f16_imm_a(
34 half addrspace(1)* %r,
35 half addrspace(1)* %b,
36 half addrspace(1)* %c) {
38 %b.val = load volatile half, half addrspace(1)* %b
39 %c.val = load volatile half, half addrspace(1)* %c
40 %r.val = call half @llvm.amdgcn.div.fixup.f16(half 3.0, half %b.val, half %c.val)
41 store half %r.val, half addrspace(1)* %r
45 ; GCN-LABEL: {{^}}div_fixup_f16_imm_b
46 ; GCN: buffer_load_ushort v[[A_F16:[0-9]+]]
47 ; GCN: buffer_load_ushort v[[C_F16:[0-9]+]]
48 ; VI: s_movk_i32 s[[B_F16:[0-9]+]], 0x4200{{$}}
49 ; VI: v_div_fixup_f16 v[[R_F16:[0-9]+]], v[[A_F16]], s[[B_F16]], v[[C_F16]]
50 ; GCN: buffer_store_short v[[R_F16]]
52 define amdgpu_kernel void @div_fixup_f16_imm_b(
53 half addrspace(1)* %r,
54 half addrspace(1)* %a,
55 half addrspace(1)* %c) {
57 %a.val = load volatile half, half addrspace(1)* %a
58 %c.val = load volatile half, half addrspace(1)* %c
59 %r.val = call half @llvm.amdgcn.div.fixup.f16(half %a.val, half 3.0, half %c.val)
60 store half %r.val, half addrspace(1)* %r
64 ; GCN-LABEL: {{^}}div_fixup_f16_imm_c
65 ; GCN: buffer_load_ushort v[[A_F16:[0-9]+]]
66 ; GCN: buffer_load_ushort v[[B_F16:[0-9]+]]
67 ; VI: s_movk_i32 s[[C_F16:[0-9]+]], 0x4200{{$}}
68 ; VI: v_div_fixup_f16 v[[R_F16:[0-9]+]], v[[A_F16]], v[[B_F16]], s[[C_F16]]
69 ; GCN: buffer_store_short v[[R_F16]]
71 define amdgpu_kernel void @div_fixup_f16_imm_c(
72 half addrspace(1)* %r,
73 half addrspace(1)* %a,
74 half addrspace(1)* %b) {
76 %a.val = load volatile half, half addrspace(1)* %a
77 %b.val = load volatile half, half addrspace(1)* %b
78 %r.val = call half @llvm.amdgcn.div.fixup.f16(half %a.val, half %b.val, half 3.0)
79 store half %r.val, half addrspace(1)* %r
83 ; GCN-LABEL: {{^}}div_fixup_f16_imm_a_imm_b
84 ; VI-DAG: s_movk_i32 [[AB_F16:s[0-9]+]], 0x4200{{$}}
85 ; GCN-DAG: buffer_load_ushort v[[C_F16:[0-9]+]]
86 ; VI: v_div_fixup_f16 v[[R_F16:[0-9]+]], [[AB_F16]], [[AB_F16]], v[[C_F16]]
87 ; GCN: buffer_store_short v[[R_F16]]
89 define amdgpu_kernel void @div_fixup_f16_imm_a_imm_b(
90 half addrspace(1)* %r,
91 half addrspace(1)* %c) {
93 %c.val = load volatile half, half addrspace(1)* %c
94 %r.val = call half @llvm.amdgcn.div.fixup.f16(half 3.0, half 3.0, half %c.val)
95 store half %r.val, half addrspace(1)* %r
99 ; GCN-LABEL: {{^}}div_fixup_f16_imm_b_imm_c
100 ; VI-DAG: s_movk_i32 [[BC_F16:s[0-9]+]], 0x4200{{$}}
101 ; GCN-DAG: buffer_load_ushort v[[A_F16:[0-9]+]]
102 ; VI: v_div_fixup_f16 v[[R_F16:[0-9]+]], v[[A_F16]], [[BC_F16]], [[BC_F16]]
103 ; GCN: buffer_store_short v[[R_F16]]
105 define amdgpu_kernel void @div_fixup_f16_imm_b_imm_c(
106 half addrspace(1)* %r,
107 half addrspace(1)* %a) {
109 %a.val = load half, half addrspace(1)* %a
110 %r.val = call half @llvm.amdgcn.div.fixup.f16(half %a.val, half 3.0, half 3.0)
111 store half %r.val, half addrspace(1)* %r
115 ; GCN-LABEL: {{^}}div_fixup_f16_imm_a_imm_c
116 ; VI-DAG: s_movk_i32 [[AC_F16:s[0-9]+]], 0x4200{{$}}
117 ; GCN-DAG: buffer_load_ushort v[[B_F16:[0-9]+]]
118 ; VI: v_div_fixup_f16 v[[R_F16:[0-9]+]], [[AC_F16]], v[[B_F16]], [[AC_F16]]
119 ; GCN: buffer_store_short v[[R_F16]]
121 define amdgpu_kernel void @div_fixup_f16_imm_a_imm_c(
122 half addrspace(1)* %r,
123 half addrspace(1)* %b) {
125 %b.val = load half, half addrspace(1)* %b
126 %r.val = call half @llvm.amdgcn.div.fixup.f16(half 3.0, half %b.val, half 3.0)
127 store half %r.val, half addrspace(1)* %r