|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py |
| 2 | +; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=fiji -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefixes=VI %s |
| 3 | +; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=gfx1010 -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX10 %s |
| 4 | +; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=gfx1100 -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX11 %s |
| 5 | + |
| 6 | +declare half @llvm.amdgcn.ldexp.f16(half %a, i32 %b) |
| 7 | + |
| 8 | +define amdgpu_kernel void @ldexp_f16( |
| 9 | +; VI-LABEL: ldexp_f16: |
| 10 | +; VI: ; %bb.0: |
| 11 | +; VI-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24 |
| 12 | +; VI-NEXT: s_load_dwordx2 s[8:9], s[0:1], 0x34 |
| 13 | +; VI-NEXT: s_mov_b32 s3, 0xf000 |
| 14 | +; VI-NEXT: s_mov_b32 s2, -1 |
| 15 | +; VI-NEXT: s_mov_b32 s10, s2 |
| 16 | +; VI-NEXT: s_mov_b32 s11, s3 |
| 17 | +; VI-NEXT: s_waitcnt lgkmcnt(0) |
| 18 | +; VI-NEXT: s_mov_b32 s12, s6 |
| 19 | +; VI-NEXT: s_mov_b32 s13, s7 |
| 20 | +; VI-NEXT: s_mov_b32 s14, s2 |
| 21 | +; VI-NEXT: s_mov_b32 s15, s3 |
| 22 | +; VI-NEXT: buffer_load_dword v0, off, s[8:11], 0 |
| 23 | +; VI-NEXT: buffer_load_ushort v1, off, s[12:15], 0 |
| 24 | +; VI-NEXT: s_mov_b32 s0, s4 |
| 25 | +; VI-NEXT: s_movk_i32 s4, 0x8000 |
| 26 | +; VI-NEXT: v_mov_b32_e32 v2, 0x7fff |
| 27 | +; VI-NEXT: s_mov_b32 s1, s5 |
| 28 | +; VI-NEXT: s_waitcnt vmcnt(1) |
| 29 | +; VI-NEXT: v_med3_i32 v0, v0, s4, v2 |
| 30 | +; VI-NEXT: s_waitcnt vmcnt(0) |
| 31 | +; VI-NEXT: v_ldexp_f16_e32 v0, v1, v0 |
| 32 | +; VI-NEXT: buffer_store_short v0, off, s[0:3], 0 |
| 33 | +; VI-NEXT: s_endpgm |
| 34 | +; |
| 35 | +; GFX10-LABEL: ldexp_f16: |
| 36 | +; GFX10: ; %bb.0: |
| 37 | +; GFX10-NEXT: s_clause 0x1 |
| 38 | +; GFX10-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24 |
| 39 | +; GFX10-NEXT: s_load_dwordx2 s[8:9], s[0:1], 0x34 |
| 40 | +; GFX10-NEXT: s_mov_b32 s2, -1 |
| 41 | +; GFX10-NEXT: s_mov_b32 s3, 0x31016000 |
| 42 | +; GFX10-NEXT: s_mov_b32 s10, s2 |
| 43 | +; GFX10-NEXT: s_mov_b32 s11, s3 |
| 44 | +; GFX10-NEXT: s_mov_b32 s14, s2 |
| 45 | +; GFX10-NEXT: s_mov_b32 s15, s3 |
| 46 | +; GFX10-NEXT: s_movk_i32 s0, 0x8000 |
| 47 | +; GFX10-NEXT: s_waitcnt lgkmcnt(0) |
| 48 | +; GFX10-NEXT: s_mov_b32 s12, s6 |
| 49 | +; GFX10-NEXT: buffer_load_dword v0, off, s[8:11], 0 |
| 50 | +; GFX10-NEXT: s_mov_b32 s13, s7 |
| 51 | +; GFX10-NEXT: s_mov_b32 s1, s5 |
| 52 | +; GFX10-NEXT: buffer_load_ushort v1, off, s[12:15], 0 |
| 53 | +; GFX10-NEXT: s_waitcnt vmcnt(1) |
| 54 | +; GFX10-NEXT: v_med3_i32 v0, v0, s0, 0x7fff |
| 55 | +; GFX10-NEXT: s_mov_b32 s0, s4 |
| 56 | +; GFX10-NEXT: s_waitcnt vmcnt(0) |
| 57 | +; GFX10-NEXT: v_ldexp_f16_e32 v0, v1, v0 |
| 58 | +; GFX10-NEXT: buffer_store_short v0, off, s[0:3], 0 |
| 59 | +; GFX10-NEXT: s_endpgm |
| 60 | +; |
| 61 | +; GFX11-LABEL: ldexp_f16: |
| 62 | +; GFX11: ; %bb.0: |
| 63 | +; GFX11-NEXT: s_clause 0x1 |
| 64 | +; GFX11-NEXT: s_load_b128 s[4:7], s[0:1], 0x24 |
| 65 | +; GFX11-NEXT: s_load_b64 s[0:1], s[0:1], 0x34 |
| 66 | +; GFX11-NEXT: s_mov_b32 s10, -1 |
| 67 | +; GFX11-NEXT: s_mov_b32 s11, 0x31016000 |
| 68 | +; GFX11-NEXT: s_mov_b32 s2, s10 |
| 69 | +; GFX11-NEXT: s_mov_b32 s3, s11 |
| 70 | +; GFX11-NEXT: s_mov_b32 s14, s10 |
| 71 | +; GFX11-NEXT: s_mov_b32 s15, s11 |
| 72 | +; GFX11-NEXT: s_waitcnt lgkmcnt(0) |
| 73 | +; GFX11-NEXT: s_mov_b32 s12, s6 |
| 74 | +; GFX11-NEXT: buffer_load_b32 v0, off, s[0:3], 0 |
| 75 | +; GFX11-NEXT: s_mov_b32 s13, s7 |
| 76 | +; GFX11-NEXT: s_movk_i32 s0, 0x8000 |
| 77 | +; GFX11-NEXT: buffer_load_u16 v1, off, s[12:15], 0 |
| 78 | +; GFX11-NEXT: s_mov_b32 s8, s4 |
| 79 | +; GFX11-NEXT: s_mov_b32 s9, s5 |
| 80 | +; GFX11-NEXT: s_waitcnt vmcnt(1) |
| 81 | +; GFX11-NEXT: v_med3_i32 v0, v0, s0, 0x7fff |
| 82 | +; GFX11-NEXT: s_waitcnt vmcnt(0) |
| 83 | +; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1) |
| 84 | +; GFX11-NEXT: v_ldexp_f16_e32 v0, v1, v0 |
| 85 | +; GFX11-NEXT: buffer_store_b16 v0, off, s[8:11], 0 |
| 86 | +; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) |
| 87 | +; GFX11-NEXT: s_endpgm |
| 88 | + ptr addrspace(1) %r, |
| 89 | + ptr addrspace(1) %a, |
| 90 | + ptr addrspace(1) %b) { |
| 91 | + %a.val = load half, ptr addrspace(1) %a |
| 92 | + %b.val = load i32, ptr addrspace(1) %b |
| 93 | + %r.val = call half @llvm.amdgcn.ldexp.f16(half %a.val, i32 %b.val) |
| 94 | + store half %r.val, ptr addrspace(1) %r |
| 95 | + ret void |
| 96 | +} |
| 97 | + |
| 98 | +define amdgpu_kernel void @ldexp_f16_imm_a( |
| 99 | +; VI-LABEL: ldexp_f16_imm_a: |
| 100 | +; VI: ; %bb.0: |
| 101 | +; VI-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24 |
| 102 | +; VI-NEXT: s_mov_b32 s7, 0xf000 |
| 103 | +; VI-NEXT: s_mov_b32 s6, -1 |
| 104 | +; VI-NEXT: s_mov_b32 s10, s6 |
| 105 | +; VI-NEXT: s_mov_b32 s11, s7 |
| 106 | +; VI-NEXT: s_waitcnt lgkmcnt(0) |
| 107 | +; VI-NEXT: s_mov_b32 s8, s2 |
| 108 | +; VI-NEXT: s_mov_b32 s9, s3 |
| 109 | +; VI-NEXT: buffer_load_dword v0, off, s[8:11], 0 |
| 110 | +; VI-NEXT: s_mov_b32 s4, s0 |
| 111 | +; VI-NEXT: s_movk_i32 s0, 0x8000 |
| 112 | +; VI-NEXT: v_mov_b32_e32 v1, 0x7fff |
| 113 | +; VI-NEXT: s_mov_b32 s5, s1 |
| 114 | +; VI-NEXT: s_waitcnt vmcnt(0) |
| 115 | +; VI-NEXT: v_med3_i32 v0, v0, s0, v1 |
| 116 | +; VI-NEXT: v_ldexp_f16_e32 v0, 2.0, v0 |
| 117 | +; VI-NEXT: buffer_store_short v0, off, s[4:7], 0 |
| 118 | +; VI-NEXT: s_endpgm |
| 119 | +; |
| 120 | +; GFX10-LABEL: ldexp_f16_imm_a: |
| 121 | +; GFX10: ; %bb.0: |
| 122 | +; GFX10-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24 |
| 123 | +; GFX10-NEXT: s_mov_b32 s6, -1 |
| 124 | +; GFX10-NEXT: s_mov_b32 s7, 0x31016000 |
| 125 | +; GFX10-NEXT: s_mov_b32 s10, s6 |
| 126 | +; GFX10-NEXT: s_mov_b32 s11, s7 |
| 127 | +; GFX10-NEXT: s_waitcnt lgkmcnt(0) |
| 128 | +; GFX10-NEXT: s_mov_b32 s8, s2 |
| 129 | +; GFX10-NEXT: s_mov_b32 s9, s3 |
| 130 | +; GFX10-NEXT: s_movk_i32 s2, 0x8000 |
| 131 | +; GFX10-NEXT: buffer_load_dword v0, off, s[8:11], 0 |
| 132 | +; GFX10-NEXT: s_mov_b32 s4, s0 |
| 133 | +; GFX10-NEXT: s_mov_b32 s5, s1 |
| 134 | +; GFX10-NEXT: s_waitcnt vmcnt(0) |
| 135 | +; GFX10-NEXT: v_med3_i32 v0, v0, s2, 0x7fff |
| 136 | +; GFX10-NEXT: v_ldexp_f16_e32 v0, 2.0, v0 |
| 137 | +; GFX10-NEXT: buffer_store_short v0, off, s[4:7], 0 |
| 138 | +; GFX10-NEXT: s_endpgm |
| 139 | +; |
| 140 | +; GFX11-LABEL: ldexp_f16_imm_a: |
| 141 | +; GFX11: ; %bb.0: |
| 142 | +; GFX11-NEXT: s_load_b128 s[0:3], s[0:1], 0x24 |
| 143 | +; GFX11-NEXT: s_mov_b32 s6, -1 |
| 144 | +; GFX11-NEXT: s_mov_b32 s7, 0x31016000 |
| 145 | +; GFX11-NEXT: s_mov_b32 s10, s6 |
| 146 | +; GFX11-NEXT: s_mov_b32 s11, s7 |
| 147 | +; GFX11-NEXT: s_waitcnt lgkmcnt(0) |
| 148 | +; GFX11-NEXT: s_mov_b32 s8, s2 |
| 149 | +; GFX11-NEXT: s_mov_b32 s9, s3 |
| 150 | +; GFX11-NEXT: s_movk_i32 s2, 0x8000 |
| 151 | +; GFX11-NEXT: buffer_load_b32 v0, off, s[8:11], 0 |
| 152 | +; GFX11-NEXT: s_mov_b32 s4, s0 |
| 153 | +; GFX11-NEXT: s_mov_b32 s5, s1 |
| 154 | +; GFX11-NEXT: s_waitcnt vmcnt(0) |
| 155 | +; GFX11-NEXT: v_med3_i32 v0, v0, s2, 0x7fff |
| 156 | +; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1) |
| 157 | +; GFX11-NEXT: v_ldexp_f16_e32 v0, 2.0, v0 |
| 158 | +; GFX11-NEXT: buffer_store_b16 v0, off, s[4:7], 0 |
| 159 | +; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) |
| 160 | +; GFX11-NEXT: s_endpgm |
| 161 | + ptr addrspace(1) %r, |
| 162 | + ptr addrspace(1) %b) { |
| 163 | + %b.val = load i32, ptr addrspace(1) %b |
| 164 | + %r.val = call half @llvm.amdgcn.ldexp.f16(half 2.0, i32 %b.val) |
| 165 | + store half %r.val, ptr addrspace(1) %r |
| 166 | + ret void |
| 167 | +} |
| 168 | + |
| 169 | +define amdgpu_kernel void @ldexp_f16_imm_b( |
| 170 | +; VI-LABEL: ldexp_f16_imm_b: |
| 171 | +; VI: ; %bb.0: |
| 172 | +; VI-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24 |
| 173 | +; VI-NEXT: s_mov_b32 s7, 0xf000 |
| 174 | +; VI-NEXT: s_mov_b32 s6, -1 |
| 175 | +; VI-NEXT: s_mov_b32 s10, s6 |
| 176 | +; VI-NEXT: s_mov_b32 s11, s7 |
| 177 | +; VI-NEXT: s_waitcnt lgkmcnt(0) |
| 178 | +; VI-NEXT: s_mov_b32 s8, s2 |
| 179 | +; VI-NEXT: s_mov_b32 s9, s3 |
| 180 | +; VI-NEXT: buffer_load_ushort v0, off, s[8:11], 0 |
| 181 | +; VI-NEXT: s_mov_b32 s4, s0 |
| 182 | +; VI-NEXT: s_mov_b32 s5, s1 |
| 183 | +; VI-NEXT: s_waitcnt vmcnt(0) |
| 184 | +; VI-NEXT: v_ldexp_f16_e64 v0, v0, 2 |
| 185 | +; VI-NEXT: buffer_store_short v0, off, s[4:7], 0 |
| 186 | +; VI-NEXT: s_endpgm |
| 187 | +; |
| 188 | +; GFX10-LABEL: ldexp_f16_imm_b: |
| 189 | +; GFX10: ; %bb.0: |
| 190 | +; GFX10-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24 |
| 191 | +; GFX10-NEXT: s_mov_b32 s6, -1 |
| 192 | +; GFX10-NEXT: s_mov_b32 s7, 0x31016000 |
| 193 | +; GFX10-NEXT: s_mov_b32 s10, s6 |
| 194 | +; GFX10-NEXT: s_mov_b32 s11, s7 |
| 195 | +; GFX10-NEXT: s_waitcnt lgkmcnt(0) |
| 196 | +; GFX10-NEXT: s_mov_b32 s8, s2 |
| 197 | +; GFX10-NEXT: s_mov_b32 s9, s3 |
| 198 | +; GFX10-NEXT: s_mov_b32 s4, s0 |
| 199 | +; GFX10-NEXT: buffer_load_ushort v0, off, s[8:11], 0 |
| 200 | +; GFX10-NEXT: s_mov_b32 s5, s1 |
| 201 | +; GFX10-NEXT: s_waitcnt vmcnt(0) |
| 202 | +; GFX10-NEXT: v_ldexp_f16_e64 v0, v0, 2 |
| 203 | +; GFX10-NEXT: buffer_store_short v0, off, s[4:7], 0 |
| 204 | +; GFX10-NEXT: s_endpgm |
| 205 | +; |
| 206 | +; GFX11-LABEL: ldexp_f16_imm_b: |
| 207 | +; GFX11: ; %bb.0: |
| 208 | +; GFX11-NEXT: s_load_b128 s[0:3], s[0:1], 0x24 |
| 209 | +; GFX11-NEXT: s_mov_b32 s6, -1 |
| 210 | +; GFX11-NEXT: s_mov_b32 s7, 0x31016000 |
| 211 | +; GFX11-NEXT: s_mov_b32 s10, s6 |
| 212 | +; GFX11-NEXT: s_mov_b32 s11, s7 |
| 213 | +; GFX11-NEXT: s_waitcnt lgkmcnt(0) |
| 214 | +; GFX11-NEXT: s_mov_b32 s8, s2 |
| 215 | +; GFX11-NEXT: s_mov_b32 s9, s3 |
| 216 | +; GFX11-NEXT: s_mov_b32 s4, s0 |
| 217 | +; GFX11-NEXT: buffer_load_u16 v0, off, s[8:11], 0 |
| 218 | +; GFX11-NEXT: s_mov_b32 s5, s1 |
| 219 | +; GFX11-NEXT: s_waitcnt vmcnt(0) |
| 220 | +; GFX11-NEXT: v_ldexp_f16_e64 v0, v0, 2 |
| 221 | +; GFX11-NEXT: buffer_store_b16 v0, off, s[4:7], 0 |
| 222 | +; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) |
| 223 | +; GFX11-NEXT: s_endpgm |
| 224 | + ptr addrspace(1) %r, |
| 225 | + ptr addrspace(1) %a) { |
| 226 | + %a.val = load half, ptr addrspace(1) %a |
| 227 | + %r.val = call half @llvm.amdgcn.ldexp.f16(half %a.val, i32 2) |
| 228 | + store half %r.val, ptr addrspace(1) %r |
| 229 | + ret void |
| 230 | +} |
0 commit comments