1 ; RUN: llc -amdgpu-scalarize-global-loads=false -mtriple=amdgcn-amd-amdhsa -mcpu=fiji -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,VI %s
3 declare half @llvm.fabs.f16(half %a)
4 declare i1 @llvm.amdgcn.class.f16(half %a, i32 %b)
6 ; GCN-LABEL: {{^}}class_f16:
7 ; GCN-DAG: buffer_load_ushort v[[A_F16:[0-9]+]]
8 ; GCN-DAG: buffer_load_dword v[[B_I32:[0-9]+]]
9 ; VI: v_cmp_class_f16_e32 vcc, v[[A_F16]], v[[B_I32]]
10 ; GCN: v_cndmask_b32_e64 v[[R_I32:[0-9]+]]
11 ; GCN: buffer_store_dword v[[R_I32]]
13 define amdgpu_kernel void @class_f16(
16 ptr addrspace(1) %b) {
18 %a.val = load half, ptr addrspace(1) %a
19 %b.val = load i32, ptr addrspace(1) %b
20 %r.val = call i1 @llvm.amdgcn.class.f16(half %a.val, i32 %b.val)
21 %r.val.sext = sext i1 %r.val to i32
22 store i32 %r.val.sext, ptr addrspace(1) %r
26 ; GCN-LABEL: {{^}}class_f16_fabs:
27 ; GCN: s_load_dword s[[SB_I32:[0-9]+]]
28 ; GCN: s_load_dword s[[SA_F16:[0-9]+]]
29 ; GCN: v_mov_b32_e32 [[V_B_I32:v[0-9]+]], s[[SB_I32]]
30 ; VI: v_cmp_class_f16_e64 [[CMP:s\[[0-9]+:[0-9]+\]]], |s[[SA_F16]]|, [[V_B_I32]]
31 ; VI: v_cndmask_b32_e64 v[[VR_I32:[0-9]+]], 0, -1, [[CMP]]
32 ; GCN: buffer_store_dword v[[VR_I32]]
34 define amdgpu_kernel void @class_f16_fabs(
41 %a.val.fabs = call half @llvm.fabs.f16(half %a.val)
42 %r.val = call i1 @llvm.amdgcn.class.f16(half %a.val.fabs, i32 %b.val)
43 %r.val.sext = sext i1 %r.val to i32
44 store i32 %r.val.sext, ptr addrspace(1) %r
48 ; GCN-LABEL: {{^}}class_f16_fneg:
49 ; GCN: s_load_dword s[[SB_I32:[0-9]+]]
50 ; GCN: s_load_dword s[[SA_F16:[0-9]+]]
51 ; GCN: v_mov_b32_e32 [[V_B_I32:v[0-9]+]], s[[SB_I32]]
52 ; VI: v_cmp_class_f16_e64 [[CMP:s\[[0-9]+:[0-9]+\]]], -s[[SA_F16]], [[V_B_I32]]
53 ; VI: v_cndmask_b32_e64 v[[VR_I32:[0-9]+]], 0, -1, [[CMP]]
54 ; GCN: buffer_store_dword v[[VR_I32]]
56 define amdgpu_kernel void @class_f16_fneg(
63 %a.val.fneg = fsub half -0.0, %a.val
64 %r.val = call i1 @llvm.amdgcn.class.f16(half %a.val.fneg, i32 %b.val)
65 %r.val.sext = sext i1 %r.val to i32
66 store i32 %r.val.sext, ptr addrspace(1) %r
70 ; GCN-LABEL: {{^}}class_f16_fabs_fneg:
71 ; GCN: s_load_dword s[[SB_I32:[0-9]+]]
72 ; GCN: s_load_dword s[[SA_F16:[0-9]+]]
73 ; GCN: v_mov_b32_e32 [[V_B_I32:v[0-9]+]], s[[SB_I32]]
74 ; VI: v_cmp_class_f16_e64 [[CMP:s\[[0-9]+:[0-9]+\]]], -|s[[SA_F16]]|, [[V_B_I32]]
75 ; VI: v_cndmask_b32_e64 v[[VR_I32:[0-9]+]], 0, -1, [[CMP]]
76 ; GCN: buffer_store_dword v[[VR_I32]]
78 define amdgpu_kernel void @class_f16_fabs_fneg(
85 %a.val.fabs = call half @llvm.fabs.f16(half %a.val)
86 %a.val.fabs.fneg = fsub half -0.0, %a.val.fabs
87 %r.val = call i1 @llvm.amdgcn.class.f16(half %a.val.fabs.fneg, i32 %b.val)
88 %r.val.sext = sext i1 %r.val to i32
89 store i32 %r.val.sext, ptr addrspace(1) %r
93 ; GCN-LABEL: {{^}}class_f16_1:
94 ; GCN: s_load_dword s[[SA_F16:[0-9]+]]
95 ; VI: v_cmp_class_f16_e64 [[CMP:s\[[0-9]+:[0-9]+\]]], s[[SA_F16]], 1{{$}}
96 ; VI: v_cndmask_b32_e64 v[[VR_I32:[0-9]+]], 0, -1, [[CMP]]
97 ; GCN: buffer_store_dword v[[VR_I32]]
99 define amdgpu_kernel void @class_f16_1(
103 %r.val = call i1 @llvm.amdgcn.class.f16(half %a.val, i32 1)
104 %r.val.sext = sext i1 %r.val to i32
105 store i32 %r.val.sext, ptr addrspace(1) %r
109 ; GCN-LABEL: {{^}}class_f16_64
110 ; GCN: s_load_dword s[[SA_F16:[0-9]+]]
111 ; VI: v_cmp_class_f16_e64 [[CMP:s\[[0-9]+:[0-9]+\]]], s[[SA_F16]], 64{{$}}
112 ; VI: v_cndmask_b32_e64 v[[VR_I32:[0-9]+]], 0, -1, [[CMP]]
113 ; GCN: buffer_store_dword v[[VR_I32]]
115 define amdgpu_kernel void @class_f16_64(
119 %r.val = call i1 @llvm.amdgcn.class.f16(half %a.val, i32 64)
120 %r.val.sext = sext i1 %r.val to i32
121 store i32 %r.val.sext, ptr addrspace(1) %r
125 ; GCN-LABEL: {{^}}class_f16_full_mask:
126 ; GCN: s_load_dword s[[SA_F16:[0-9]+]]
127 ; VI: v_mov_b32_e32 v[[MASK:[0-9]+]], 0x3ff{{$}}
128 ; VI: v_cmp_class_f16_e32 vcc, s[[SA_F16]], v[[MASK]]
129 ; VI: v_cndmask_b32_e64 v[[VR_I32:[0-9]+]], 0, -1, vcc
130 ; GCN: buffer_store_dword v[[VR_I32]]
132 define amdgpu_kernel void @class_f16_full_mask(
136 %r.val = call i1 @llvm.amdgcn.class.f16(half %a.val, i32 1023)
137 %r.val.sext = sext i1 %r.val to i32
138 store i32 %r.val.sext, ptr addrspace(1) %r
142 ; GCN-LABEL: {{^}}class_f16_nine_bit_mask:
143 ; GCN: s_load_dword s[[SA_F16:[0-9]+]]
144 ; VI: v_mov_b32_e32 v[[MASK:[0-9]+]], 0x1ff{{$}}
145 ; VI: v_cmp_class_f16_e32 vcc, s[[SA_F16]], v[[MASK]]
146 ; VI: v_cndmask_b32_e64 v[[VR_I32:[0-9]+]], 0, -1, vcc
147 ; GCN: buffer_store_dword v[[VR_I32]]
149 define amdgpu_kernel void @class_f16_nine_bit_mask(
153 %r.val = call i1 @llvm.amdgcn.class.f16(half %a.val, i32 511)
154 %r.val.sext = sext i1 %r.val to i32
155 store i32 %r.val.sext, ptr addrspace(1) %r