blob: a4663ae6c19f4cd61e657ea1e126b7e6cc494298 [file] [edit]
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
; RUN: llc -global-isel=0 -mtriple=amdgpu8.03-amd-amdhsa -mattr=-flat-for-global < %s | FileCheck -enable-var-scope -check-prefixes=GCN,VI-SDAG %s
; RUN: llc -global-isel=1 -mtriple=amdgpu8.03-amd-amdhsa -mattr=-flat-for-global < %s | FileCheck -enable-var-scope -check-prefixes=GCN,VI-GISEL %s
declare half @llvm.fabs.f16(half %a)
declare i1 @llvm.amdgcn.class.f16(half %a, i32 %b)
define i32 @class_f16(half %a, i32 %b) {
; GCN-LABEL: class_f16:
; GCN: ; %bb.0:
; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GCN-NEXT: v_cmp_class_f16_e32 vcc, v0, v1
; GCN-NEXT: v_cndmask_b32_e64 v0, 0, -1, vcc
; GCN-NEXT: s_setpc_b64 s[30:31]
%r.val = call i1 @llvm.amdgcn.class.f16(half %a, i32 %b)
%r.val.sext = sext i1 %r.val to i32
ret i32 %r.val.sext
}
define amdgpu_kernel void @class_f16_fabs(
; VI-SDAG-LABEL: class_f16_fabs:
; VI-SDAG: ; %bb.0: ; %entry
; VI-SDAG-NEXT: s_load_dword s4, s[8:9], 0x4c
; VI-SDAG-NEXT: s_load_dword s5, s[8:9], 0x28
; VI-SDAG-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0
; VI-SDAG-NEXT: s_mov_b32 s3, 0x1100f000
; VI-SDAG-NEXT: s_mov_b32 s2, -1
; VI-SDAG-NEXT: s_waitcnt lgkmcnt(0)
; VI-SDAG-NEXT: v_mov_b32_e32 v0, s4
; VI-SDAG-NEXT: v_cmp_class_f16_e64 s[4:5], |s5|, v0
; VI-SDAG-NEXT: s_cmp_lg_u64 s[4:5], 0
; VI-SDAG-NEXT: s_cselect_b32 s4, -1, 0
; VI-SDAG-NEXT: v_mov_b32_e32 v0, s4
; VI-SDAG-NEXT: buffer_store_dword v0, off, s[0:3], 0
; VI-SDAG-NEXT: s_endpgm
;
; VI-GISEL-LABEL: class_f16_fabs:
; VI-GISEL: ; %bb.0: ; %entry
; VI-GISEL-NEXT: s_load_dword s3, s[8:9], 0x4c
; VI-GISEL-NEXT: s_load_dword s4, s[8:9], 0x28
; VI-GISEL-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0
; VI-GISEL-NEXT: s_mov_b32 s2, -1
; VI-GISEL-NEXT: s_waitcnt lgkmcnt(0)
; VI-GISEL-NEXT: v_mov_b32_e32 v0, s3
; VI-GISEL-NEXT: v_cmp_class_f16_e64 s[4:5], |s4|, v0
; VI-GISEL-NEXT: s_cmp_lg_u64 s[4:5], 0
; VI-GISEL-NEXT: s_cselect_b32 s3, -1, 0
; VI-GISEL-NEXT: v_mov_b32_e32 v0, s3
; VI-GISEL-NEXT: s_mov_b32 s3, 0x1100f000
; VI-GISEL-NEXT: buffer_store_dword v0, off, s[0:3], 0
; VI-GISEL-NEXT: s_endpgm
ptr addrspace(1) %r,
[8 x i32],
half %a.val,
[8 x i32],
i32 %b.val) {
entry:
%a.val.fabs = call half @llvm.fabs.f16(half %a.val)
%r.val = call i1 @llvm.amdgcn.class.f16(half %a.val.fabs, i32 %b.val)
%r.val.sext = sext i1 %r.val to i32
store i32 %r.val.sext, ptr addrspace(1) %r
ret void
}
define amdgpu_kernel void @class_f16_fneg(
; VI-SDAG-LABEL: class_f16_fneg:
; VI-SDAG: ; %bb.0: ; %entry
; VI-SDAG-NEXT: s_load_dword s4, s[8:9], 0x4c
; VI-SDAG-NEXT: s_load_dword s5, s[8:9], 0x28
; VI-SDAG-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0
; VI-SDAG-NEXT: s_mov_b32 s3, 0x1100f000
; VI-SDAG-NEXT: s_mov_b32 s2, -1
; VI-SDAG-NEXT: s_waitcnt lgkmcnt(0)
; VI-SDAG-NEXT: v_mov_b32_e32 v0, s4
; VI-SDAG-NEXT: v_cmp_class_f16_e64 s[4:5], -s5, v0
; VI-SDAG-NEXT: s_cmp_lg_u64 s[4:5], 0
; VI-SDAG-NEXT: s_cselect_b32 s4, -1, 0
; VI-SDAG-NEXT: v_mov_b32_e32 v0, s4
; VI-SDAG-NEXT: buffer_store_dword v0, off, s[0:3], 0
; VI-SDAG-NEXT: s_endpgm
;
; VI-GISEL-LABEL: class_f16_fneg:
; VI-GISEL: ; %bb.0: ; %entry
; VI-GISEL-NEXT: s_load_dword s3, s[8:9], 0x28
; VI-GISEL-NEXT: s_load_dword s4, s[8:9], 0x4c
; VI-GISEL-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0
; VI-GISEL-NEXT: s_mov_b32 s2, -1
; VI-GISEL-NEXT: s_waitcnt lgkmcnt(0)
; VI-GISEL-NEXT: v_max_f16_e64 v0, -s3, -s3
; VI-GISEL-NEXT: v_cmp_class_f16_e64 s[4:5], v0, s4
; VI-GISEL-NEXT: s_cmp_lg_u64 s[4:5], 0
; VI-GISEL-NEXT: s_cselect_b32 s3, -1, 0
; VI-GISEL-NEXT: v_mov_b32_e32 v0, s3
; VI-GISEL-NEXT: s_mov_b32 s3, 0x1100f000
; VI-GISEL-NEXT: buffer_store_dword v0, off, s[0:3], 0
; VI-GISEL-NEXT: s_endpgm
ptr addrspace(1) %r,
[8 x i32],
half %a.val,
[8 x i32],
i32 %b.val) {
entry:
%a.val.fneg = fsub half -0.0, %a.val
%r.val = call i1 @llvm.amdgcn.class.f16(half %a.val.fneg, i32 %b.val)
%r.val.sext = sext i1 %r.val to i32
store i32 %r.val.sext, ptr addrspace(1) %r
ret void
}
define amdgpu_kernel void @class_f16_fabs_fneg(
; VI-SDAG-LABEL: class_f16_fabs_fneg:
; VI-SDAG: ; %bb.0: ; %entry
; VI-SDAG-NEXT: s_load_dword s4, s[8:9], 0x4c
; VI-SDAG-NEXT: s_load_dword s5, s[8:9], 0x28
; VI-SDAG-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0
; VI-SDAG-NEXT: s_mov_b32 s3, 0x1100f000
; VI-SDAG-NEXT: s_mov_b32 s2, -1
; VI-SDAG-NEXT: s_waitcnt lgkmcnt(0)
; VI-SDAG-NEXT: v_mov_b32_e32 v0, s4
; VI-SDAG-NEXT: v_cmp_class_f16_e64 s[4:5], -|s5|, v0
; VI-SDAG-NEXT: s_cmp_lg_u64 s[4:5], 0
; VI-SDAG-NEXT: s_cselect_b32 s4, -1, 0
; VI-SDAG-NEXT: v_mov_b32_e32 v0, s4
; VI-SDAG-NEXT: buffer_store_dword v0, off, s[0:3], 0
; VI-SDAG-NEXT: s_endpgm
;
; VI-GISEL-LABEL: class_f16_fabs_fneg:
; VI-GISEL: ; %bb.0: ; %entry
; VI-GISEL-NEXT: s_load_dword s3, s[8:9], 0x28
; VI-GISEL-NEXT: s_load_dword s4, s[8:9], 0x4c
; VI-GISEL-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0
; VI-GISEL-NEXT: s_mov_b32 s2, -1
; VI-GISEL-NEXT: s_waitcnt lgkmcnt(0)
; VI-GISEL-NEXT: v_max_f16_e64 v0, -|s3|, -|s3|
; VI-GISEL-NEXT: v_cmp_class_f16_e64 s[4:5], v0, s4
; VI-GISEL-NEXT: s_cmp_lg_u64 s[4:5], 0
; VI-GISEL-NEXT: s_cselect_b32 s3, -1, 0
; VI-GISEL-NEXT: v_mov_b32_e32 v0, s3
; VI-GISEL-NEXT: s_mov_b32 s3, 0x1100f000
; VI-GISEL-NEXT: buffer_store_dword v0, off, s[0:3], 0
; VI-GISEL-NEXT: s_endpgm
ptr addrspace(1) %r,
[8 x i32],
half %a.val,
[8 x i32],
i32 %b.val) {
entry:
%a.val.fabs = call half @llvm.fabs.f16(half %a.val)
%a.val.fabs.fneg = fsub half -0.0, %a.val.fabs
%r.val = call i1 @llvm.amdgcn.class.f16(half %a.val.fabs.fneg, i32 %b.val)
%r.val.sext = sext i1 %r.val to i32
store i32 %r.val.sext, ptr addrspace(1) %r
ret void
}
define amdgpu_kernel void @class_f16_1(
; VI-SDAG-LABEL: class_f16_1:
; VI-SDAG: ; %bb.0: ; %entry
; VI-SDAG-NEXT: s_load_dword s4, s[8:9], 0x8
; VI-SDAG-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0
; VI-SDAG-NEXT: s_mov_b32 s3, 0x1100f000
; VI-SDAG-NEXT: s_mov_b32 s2, -1
; VI-SDAG-NEXT: s_waitcnt lgkmcnt(0)
; VI-SDAG-NEXT: v_cmp_class_f16_e64 s[4:5], s4, 1
; VI-SDAG-NEXT: s_cmp_lg_u64 s[4:5], 0
; VI-SDAG-NEXT: s_cselect_b32 s4, -1, 0
; VI-SDAG-NEXT: v_mov_b32_e32 v0, s4
; VI-SDAG-NEXT: buffer_store_dword v0, off, s[0:3], 0
; VI-SDAG-NEXT: s_endpgm
;
; VI-GISEL-LABEL: class_f16_1:
; VI-GISEL: ; %bb.0: ; %entry
; VI-GISEL-NEXT: s_load_dword s3, s[8:9], 0x8
; VI-GISEL-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0
; VI-GISEL-NEXT: s_mov_b32 s2, -1
; VI-GISEL-NEXT: s_waitcnt lgkmcnt(0)
; VI-GISEL-NEXT: v_cmp_class_f16_e64 s[4:5], s3, 1
; VI-GISEL-NEXT: s_cmp_lg_u64 s[4:5], 0
; VI-GISEL-NEXT: s_cselect_b32 s3, -1, 0
; VI-GISEL-NEXT: v_mov_b32_e32 v0, s3
; VI-GISEL-NEXT: s_mov_b32 s3, 0x1100f000
; VI-GISEL-NEXT: buffer_store_dword v0, off, s[0:3], 0
; VI-GISEL-NEXT: s_endpgm
ptr addrspace(1) %r,
half %a.val) {
entry:
%r.val = call i1 @llvm.amdgcn.class.f16(half %a.val, i32 1)
%r.val.sext = sext i1 %r.val to i32
store i32 %r.val.sext, ptr addrspace(1) %r
ret void
}
define amdgpu_kernel void @class_f16_64(
; VI-SDAG-LABEL: class_f16_64:
; VI-SDAG: ; %bb.0: ; %entry
; VI-SDAG-NEXT: s_load_dword s4, s[8:9], 0x8
; VI-SDAG-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0
; VI-SDAG-NEXT: s_mov_b32 s3, 0x1100f000
; VI-SDAG-NEXT: s_mov_b32 s2, -1
; VI-SDAG-NEXT: s_waitcnt lgkmcnt(0)
; VI-SDAG-NEXT: v_cmp_class_f16_e64 s[4:5], s4, 64
; VI-SDAG-NEXT: s_cmp_lg_u64 s[4:5], 0
; VI-SDAG-NEXT: s_cselect_b32 s4, -1, 0
; VI-SDAG-NEXT: v_mov_b32_e32 v0, s4
; VI-SDAG-NEXT: buffer_store_dword v0, off, s[0:3], 0
; VI-SDAG-NEXT: s_endpgm
;
; VI-GISEL-LABEL: class_f16_64:
; VI-GISEL: ; %bb.0: ; %entry
; VI-GISEL-NEXT: s_load_dword s3, s[8:9], 0x8
; VI-GISEL-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0
; VI-GISEL-NEXT: s_mov_b32 s2, -1
; VI-GISEL-NEXT: s_waitcnt lgkmcnt(0)
; VI-GISEL-NEXT: v_cmp_class_f16_e64 s[4:5], s3, 64
; VI-GISEL-NEXT: s_cmp_lg_u64 s[4:5], 0
; VI-GISEL-NEXT: s_cselect_b32 s3, -1, 0
; VI-GISEL-NEXT: v_mov_b32_e32 v0, s3
; VI-GISEL-NEXT: s_mov_b32 s3, 0x1100f000
; VI-GISEL-NEXT: buffer_store_dword v0, off, s[0:3], 0
; VI-GISEL-NEXT: s_endpgm
ptr addrspace(1) %r,
half %a.val) {
entry:
%r.val = call i1 @llvm.amdgcn.class.f16(half %a.val, i32 64)
%r.val.sext = sext i1 %r.val to i32
store i32 %r.val.sext, ptr addrspace(1) %r
ret void
}
define amdgpu_kernel void @class_f16_full_mask(
; VI-SDAG-LABEL: class_f16_full_mask:
; VI-SDAG: ; %bb.0: ; %entry
; VI-SDAG-NEXT: s_load_dword s4, s[8:9], 0x8
; VI-SDAG-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0
; VI-SDAG-NEXT: v_mov_b32_e32 v0, 0x3ff
; VI-SDAG-NEXT: s_mov_b32 s3, 0x1100f000
; VI-SDAG-NEXT: s_mov_b32 s2, -1
; VI-SDAG-NEXT: s_waitcnt lgkmcnt(0)
; VI-SDAG-NEXT: v_cmp_class_f16_e32 vcc, s4, v0
; VI-SDAG-NEXT: s_cmp_lg_u64 vcc, 0
; VI-SDAG-NEXT: s_cselect_b32 s4, -1, 0
; VI-SDAG-NEXT: v_mov_b32_e32 v0, s4
; VI-SDAG-NEXT: buffer_store_dword v0, off, s[0:3], 0
; VI-SDAG-NEXT: s_endpgm
;
; VI-GISEL-LABEL: class_f16_full_mask:
; VI-GISEL: ; %bb.0: ; %entry
; VI-GISEL-NEXT: s_load_dword s3, s[8:9], 0x8
; VI-GISEL-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0
; VI-GISEL-NEXT: v_mov_b32_e32 v0, 0x3ff
; VI-GISEL-NEXT: s_mov_b32 s2, -1
; VI-GISEL-NEXT: s_waitcnt lgkmcnt(0)
; VI-GISEL-NEXT: v_cmp_class_f16_e32 vcc, s3, v0
; VI-GISEL-NEXT: s_cmp_lg_u64 vcc, 0
; VI-GISEL-NEXT: s_cselect_b32 s3, -1, 0
; VI-GISEL-NEXT: v_mov_b32_e32 v0, s3
; VI-GISEL-NEXT: s_mov_b32 s3, 0x1100f000
; VI-GISEL-NEXT: buffer_store_dword v0, off, s[0:3], 0
; VI-GISEL-NEXT: s_endpgm
ptr addrspace(1) %r,
half %a.val) {
entry:
%r.val = call i1 @llvm.amdgcn.class.f16(half %a.val, i32 1023)
%r.val.sext = sext i1 %r.val to i32
store i32 %r.val.sext, ptr addrspace(1) %r
ret void
}
define amdgpu_kernel void @class_f16_nine_bit_mask(
; VI-SDAG-LABEL: class_f16_nine_bit_mask:
; VI-SDAG: ; %bb.0: ; %entry
; VI-SDAG-NEXT: s_load_dword s4, s[8:9], 0x8
; VI-SDAG-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0
; VI-SDAG-NEXT: v_mov_b32_e32 v0, 0x1ff
; VI-SDAG-NEXT: s_mov_b32 s3, 0x1100f000
; VI-SDAG-NEXT: s_mov_b32 s2, -1
; VI-SDAG-NEXT: s_waitcnt lgkmcnt(0)
; VI-SDAG-NEXT: v_cmp_class_f16_e32 vcc, s4, v0
; VI-SDAG-NEXT: s_cmp_lg_u64 vcc, 0
; VI-SDAG-NEXT: s_cselect_b32 s4, -1, 0
; VI-SDAG-NEXT: v_mov_b32_e32 v0, s4
; VI-SDAG-NEXT: buffer_store_dword v0, off, s[0:3], 0
; VI-SDAG-NEXT: s_endpgm
;
; VI-GISEL-LABEL: class_f16_nine_bit_mask:
; VI-GISEL: ; %bb.0: ; %entry
; VI-GISEL-NEXT: s_load_dword s3, s[8:9], 0x8
; VI-GISEL-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0
; VI-GISEL-NEXT: v_mov_b32_e32 v0, 0x1ff
; VI-GISEL-NEXT: s_mov_b32 s2, -1
; VI-GISEL-NEXT: s_waitcnt lgkmcnt(0)
; VI-GISEL-NEXT: v_cmp_class_f16_e32 vcc, s3, v0
; VI-GISEL-NEXT: s_cmp_lg_u64 vcc, 0
; VI-GISEL-NEXT: s_cselect_b32 s3, -1, 0
; VI-GISEL-NEXT: v_mov_b32_e32 v0, s3
; VI-GISEL-NEXT: s_mov_b32 s3, 0x1100f000
; VI-GISEL-NEXT: buffer_store_dword v0, off, s[0:3], 0
; VI-GISEL-NEXT: s_endpgm
ptr addrspace(1) %r,
half %a.val) {
entry:
%r.val = call i1 @llvm.amdgcn.class.f16(half %a.val, i32 511)
%r.val.sext = sext i1 %r.val to i32
store i32 %r.val.sext, ptr addrspace(1) %r
ret void
}