2018-07-12 04:25:49 +08:00
|
|
|
; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=tahiti -mattr=-fp64-fp16-denormals -verify-machineinstrs < %s | FileCheck -allow-deprecated-dag-overlap -check-prefix=GCN -check-prefix=SI %s
|
|
|
|
; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=fiji -mattr=-fp64-fp16-denormals,-flat-for-global -verify-machineinstrs < %s | FileCheck -allow-deprecated-dag-overlap -check-prefix=GCN -check-prefix=VI %s
|
2016-11-13 15:01:11 +08:00
|
|
|
|
2017-01-31 00:57:41 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_f16:
|
2017-01-25 06:02:15 +08:00
|
|
|
; GCN: {{buffer|flat}}_load_ushort v[[A_F16:[0-9]+]]
|
|
|
|
; GCN: {{buffer|flat}}_load_ushort v[[B_F16:[0-9]+]]
|
|
|
|
; GCN: {{buffer|flat}}_load_ushort v[[C_F16:[0-9]+]]
|
2016-11-13 15:01:11 +08:00
|
|
|
; SI: v_cvt_f32_f16_e32 v[[A_F32:[0-9]+]], v[[A_F16]]
|
|
|
|
; SI: v_cvt_f32_f16_e32 v[[B_F32:[0-9]+]], v[[B_F16]]
|
|
|
|
; SI: v_cvt_f32_f16_e32 v[[C_F32:[0-9]+]], v[[C_F16]]
|
2017-07-11 03:53:57 +08:00
|
|
|
; SI: v_mac_f32_e32 v[[C_F32]], v[[A_F32]], v[[B_F32]]
|
2016-11-13 15:01:11 +08:00
|
|
|
; SI: v_cvt_f16_f32_e32 v[[R_F16:[0-9]+]], v[[C_F32]]
|
|
|
|
; SI: buffer_store_short v[[R_F16]]
|
2017-07-11 03:53:57 +08:00
|
|
|
; VI: v_mac_f16_e32 v[[C_F16]], v[[A_F16]], v[[B_F16]]
|
2016-11-13 15:01:11 +08:00
|
|
|
; VI: buffer_store_short v[[C_F16]]
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_f16(
|
2016-11-13 15:01:11 +08:00
|
|
|
half addrspace(1)* %r,
|
|
|
|
half addrspace(1)* %a,
|
|
|
|
half addrspace(1)* %b,
|
|
|
|
half addrspace(1)* %c) #0 {
|
|
|
|
entry:
|
|
|
|
%a.val = load half, half addrspace(1)* %a
|
|
|
|
%b.val = load half, half addrspace(1)* %b
|
|
|
|
%c.val = load half, half addrspace(1)* %c
|
|
|
|
|
|
|
|
%t.val = fmul half %a.val, %b.val
|
|
|
|
%r.val = fadd half %t.val, %c.val
|
|
|
|
|
|
|
|
store half %r.val, half addrspace(1)* %r
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-02 10:27:04 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_f16_same_add:
|
2016-11-13 15:01:11 +08:00
|
|
|
; SI: v_mad_f32 v{{[0-9]}}, v{{[0-9]+}}, v{{[0-9]+}}, [[ADD:v[0-9]+]]
|
|
|
|
; SI: v_mac_f32_e32 [[ADD]], v{{[0-9]+}}, v{{[0-9]+}}
|
2017-02-02 10:27:04 +08:00
|
|
|
|
2016-11-13 15:01:11 +08:00
|
|
|
; VI: v_mad_f16 v{{[0-9]}}, v{{[0-9]+}}, v{{[0-9]+}}, [[ADD:v[0-9]+]]
|
|
|
|
; VI: v_mac_f16_e32 [[ADD]], v{{[0-9]+}}, v{{[0-9]+}}
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_f16_same_add(
|
2016-11-13 15:01:11 +08:00
|
|
|
half addrspace(1)* %r0,
|
|
|
|
half addrspace(1)* %r1,
|
|
|
|
half addrspace(1)* %a,
|
|
|
|
half addrspace(1)* %b,
|
|
|
|
half addrspace(1)* %c,
|
|
|
|
half addrspace(1)* %d,
|
|
|
|
half addrspace(1)* %e) #0 {
|
|
|
|
entry:
|
|
|
|
%a.val = load half, half addrspace(1)* %a
|
|
|
|
%b.val = load half, half addrspace(1)* %b
|
|
|
|
%c.val = load half, half addrspace(1)* %c
|
|
|
|
%d.val = load half, half addrspace(1)* %d
|
|
|
|
%e.val = load half, half addrspace(1)* %e
|
|
|
|
|
|
|
|
%t0.val = fmul half %a.val, %b.val
|
|
|
|
%r0.val = fadd half %t0.val, %c.val
|
|
|
|
|
|
|
|
%t1.val = fmul half %d.val, %e.val
|
|
|
|
%r1.val = fadd half %t1.val, %c.val
|
|
|
|
|
|
|
|
store half %r0.val, half addrspace(1)* %r0
|
|
|
|
store half %r1.val, half addrspace(1)* %r1
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-02 10:27:04 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_f16_neg_a:
|
2017-02-03 07:21:23 +08:00
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT_A:v[0-9]+]], v{{[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT_B:v[0-9]+]], v{{[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT_C:v[0-9]+]], v{{[0-9]+}}
|
|
|
|
; SI: v_mad_f32 v{{[0-9]+}}, -[[CVT_A]], [[CVT_B]], [[CVT_C]]
|
2017-02-02 10:27:04 +08:00
|
|
|
|
2016-11-13 15:01:11 +08:00
|
|
|
; VI-NOT: v_mac_f16
|
|
|
|
; VI: v_mad_f16 v{{[0-9]+}}, -v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_f16_neg_a(
|
2016-11-13 15:01:11 +08:00
|
|
|
half addrspace(1)* %r,
|
|
|
|
half addrspace(1)* %a,
|
|
|
|
half addrspace(1)* %b,
|
|
|
|
half addrspace(1)* %c) #0 {
|
|
|
|
entry:
|
|
|
|
%a.val = load half, half addrspace(1)* %a
|
|
|
|
%b.val = load half, half addrspace(1)* %b
|
|
|
|
%c.val = load half, half addrspace(1)* %c
|
|
|
|
|
|
|
|
%a.neg = fsub half -0.0, %a.val
|
|
|
|
%t.val = fmul half %a.neg, %b.val
|
|
|
|
%r.val = fadd half %t.val, %c.val
|
|
|
|
|
|
|
|
store half %r.val, half addrspace(1)* %r
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-02 10:27:04 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_f16_neg_b:
|
2017-02-03 07:21:23 +08:00
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT_A:v[0-9]+]], v{{[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT_B:v[0-9]+]], v{{[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT_C:v[0-9]+]], v{{[0-9]+}}
|
|
|
|
; SI: v_mad_f32 v{{[0-9]+}}, -[[CVT_A]], [[CVT_B]], [[CVT_C]]
|
|
|
|
|
2016-11-13 15:01:11 +08:00
|
|
|
; VI-NOT: v_mac_f16
|
|
|
|
; VI: v_mad_f16 v{{[0-9]+}}, -v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_f16_neg_b(
|
2016-11-13 15:01:11 +08:00
|
|
|
half addrspace(1)* %r,
|
|
|
|
half addrspace(1)* %a,
|
|
|
|
half addrspace(1)* %b,
|
|
|
|
half addrspace(1)* %c) #0 {
|
|
|
|
entry:
|
|
|
|
%a.val = load half, half addrspace(1)* %a
|
|
|
|
%b.val = load half, half addrspace(1)* %b
|
|
|
|
%c.val = load half, half addrspace(1)* %c
|
|
|
|
|
|
|
|
%b.neg = fsub half -0.0, %b.val
|
|
|
|
%t.val = fmul half %a.val, %b.neg
|
|
|
|
%r.val = fadd half %t.val, %c.val
|
|
|
|
|
|
|
|
store half %r.val, half addrspace(1)* %r
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-02 10:27:04 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_f16_neg_c:
|
|
|
|
; SI: v_cvt_f32_f16_e32
|
2017-02-03 07:21:23 +08:00
|
|
|
; SI: v_cvt_f32_f16_e32
|
|
|
|
; SI: v_cvt_f32_f16_e32
|
|
|
|
; SI: v_mad_f32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}, -v{{[0-9]+}}
|
2017-02-02 10:27:04 +08:00
|
|
|
|
2016-11-13 15:01:11 +08:00
|
|
|
; VI-NOT: v_mac_f16
|
|
|
|
; VI: v_mad_f16 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}, -v{{[0-9]+}}
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_f16_neg_c(
|
2016-11-13 15:01:11 +08:00
|
|
|
half addrspace(1)* %r,
|
|
|
|
half addrspace(1)* %a,
|
|
|
|
half addrspace(1)* %b,
|
|
|
|
half addrspace(1)* %c) #0 {
|
|
|
|
entry:
|
|
|
|
%a.val = load half, half addrspace(1)* %a
|
|
|
|
%b.val = load half, half addrspace(1)* %b
|
|
|
|
%c.val = load half, half addrspace(1)* %c
|
|
|
|
|
|
|
|
%c.neg = fsub half -0.0, %c.val
|
|
|
|
%t.val = fmul half %a.val, %b.val
|
|
|
|
%r.val = fadd half %t.val, %c.neg
|
|
|
|
|
|
|
|
store half %r.val, half addrspace(1)* %r
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-01-31 00:57:41 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_f16_neg_a_safe_fp_math:
|
|
|
|
; SI: v_sub_f32_e32 v[[NEG_A:[0-9]+]], 0, v{{[0-9]+}}
|
2017-07-11 03:53:57 +08:00
|
|
|
; SI: v_mac_f32_e32 v{{[0-9]+}}, v[[NEG_A]], v{{[0-9]+}}
|
2016-11-13 15:01:11 +08:00
|
|
|
; VI: v_sub_f16_e32 v[[NEG_A:[0-9]+]], 0, v{{[0-9]+}}
|
2017-07-11 03:53:57 +08:00
|
|
|
; VI: v_mac_f16_e32 v{{[0-9]+}}, v[[NEG_A]], v{{[0-9]+}}
|
2016-11-13 15:01:11 +08:00
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_f16_neg_a_safe_fp_math(
|
2016-11-13 15:01:11 +08:00
|
|
|
half addrspace(1)* %r,
|
|
|
|
half addrspace(1)* %a,
|
|
|
|
half addrspace(1)* %b,
|
|
|
|
half addrspace(1)* %c) #0 {
|
|
|
|
entry:
|
|
|
|
%a.val = load half, half addrspace(1)* %a
|
|
|
|
%b.val = load half, half addrspace(1)* %b
|
|
|
|
%c.val = load half, half addrspace(1)* %c
|
|
|
|
|
|
|
|
%a.neg = fsub half 0.0, %a.val
|
|
|
|
%t.val = fmul half %a.neg, %b.val
|
|
|
|
%r.val = fadd half %t.val, %c.val
|
|
|
|
|
|
|
|
store half %r.val, half addrspace(1)* %r
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-01-31 00:57:41 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_f16_neg_b_safe_fp_math:
|
|
|
|
; SI: v_sub_f32_e32 v[[NEG_A:[0-9]+]], 0, v{{[0-9]+}}
|
2017-07-11 03:53:57 +08:00
|
|
|
; SI: v_mac_f32_e32 v{{[0-9]+}}, v{{[0-9]+}}, v[[NEG_A]]
|
2016-11-13 15:01:11 +08:00
|
|
|
; VI: v_sub_f16_e32 v[[NEG_A:[0-9]+]], 0, v{{[0-9]+}}
|
2017-07-11 03:53:57 +08:00
|
|
|
; VI: v_mac_f16_e32 v{{[0-9]+}}, v{{[0-9]+}}, v[[NEG_A]]
|
2016-11-13 15:01:11 +08:00
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_f16_neg_b_safe_fp_math(
|
2016-11-13 15:01:11 +08:00
|
|
|
half addrspace(1)* %r,
|
|
|
|
half addrspace(1)* %a,
|
|
|
|
half addrspace(1)* %b,
|
|
|
|
half addrspace(1)* %c) #0 {
|
|
|
|
entry:
|
|
|
|
%a.val = load half, half addrspace(1)* %a
|
|
|
|
%b.val = load half, half addrspace(1)* %b
|
|
|
|
%c.val = load half, half addrspace(1)* %c
|
|
|
|
|
|
|
|
%b.neg = fsub half 0.0, %b.val
|
|
|
|
%t.val = fmul half %a.val, %b.neg
|
|
|
|
%r.val = fadd half %t.val, %c.val
|
|
|
|
|
|
|
|
store half %r.val, half addrspace(1)* %r
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-01-31 00:57:41 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_f16_neg_c_safe_fp_math:
|
|
|
|
; SI: v_sub_f32_e32 v[[NEG_A:[0-9]+]], 0, v{{[0-9]+}}
|
2016-11-13 15:01:11 +08:00
|
|
|
; SI: v_mac_f32_e32 v[[NEG_A]], v{{[0-9]+}}, v{{[0-9]+}}
|
|
|
|
; VI: v_sub_f16_e32 v[[NEG_A:[0-9]+]], 0, v{{[0-9]+}}
|
|
|
|
; VI: v_mac_f16_e32 v[[NEG_A]], v{{[0-9]+}}, v{{[0-9]+}}
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_f16_neg_c_safe_fp_math(
|
2016-11-13 15:01:11 +08:00
|
|
|
half addrspace(1)* %r,
|
|
|
|
half addrspace(1)* %a,
|
|
|
|
half addrspace(1)* %b,
|
|
|
|
half addrspace(1)* %c) #0 {
|
|
|
|
entry:
|
|
|
|
%a.val = load half, half addrspace(1)* %a
|
|
|
|
%b.val = load half, half addrspace(1)* %b
|
|
|
|
%c.val = load half, half addrspace(1)* %c
|
|
|
|
|
|
|
|
%c.neg = fsub half 0.0, %c.val
|
|
|
|
%t.val = fmul half %a.val, %b.val
|
|
|
|
%r.val = fadd half %t.val, %c.neg
|
|
|
|
|
|
|
|
store half %r.val, half addrspace(1)* %r
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-03-09 09:36:39 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_f16_neg_a_nsz_fp_math:
|
2017-02-03 07:21:23 +08:00
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT_A:v[0-9]+]], v{{[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT_B:v[0-9]+]], v{{[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT_C:v[0-9]+]], v{{[0-9]+}}
|
|
|
|
; SI: v_mad_f32 v{{[0-9]+}}, -[[CVT_A]], [[CVT_B]], [[CVT_C]]
|
2017-02-02 10:27:04 +08:00
|
|
|
|
2016-11-13 15:01:11 +08:00
|
|
|
; VI-NOT: v_mac_f16
|
|
|
|
; VI: v_mad_f16 v{{[0-9]+}}, -v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]}}
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_f16_neg_a_nsz_fp_math(
|
2016-11-13 15:01:11 +08:00
|
|
|
half addrspace(1)* %r,
|
|
|
|
half addrspace(1)* %a,
|
|
|
|
half addrspace(1)* %b,
|
|
|
|
half addrspace(1)* %c) #1 {
|
|
|
|
entry:
|
|
|
|
%a.val = load half, half addrspace(1)* %a
|
|
|
|
%b.val = load half, half addrspace(1)* %b
|
|
|
|
%c.val = load half, half addrspace(1)* %c
|
|
|
|
|
|
|
|
%a.neg = fsub half 0.0, %a.val
|
|
|
|
%t.val = fmul half %a.neg, %b.val
|
|
|
|
%r.val = fadd half %t.val, %c.val
|
|
|
|
|
|
|
|
store half %r.val, half addrspace(1)* %r
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-03-09 09:36:39 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_f16_neg_b_nsz_fp_math:
|
2017-02-03 07:21:23 +08:00
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT_A:v[0-9]+]], v{{[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT_B:v[0-9]+]], v{{[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT_C:v[0-9]+]], v{{[0-9]+}}
|
|
|
|
; SI: v_mad_f32 v{{[0-9]+}}, -[[CVT_A]], [[CVT_B]], [[CVT_C]]
|
2017-02-02 10:27:04 +08:00
|
|
|
|
2016-11-13 15:01:11 +08:00
|
|
|
; VI-NOT: v_mac_f16
|
|
|
|
; VI: v_mad_f16 v{{[0-9]+}}, -v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]}}
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_f16_neg_b_nsz_fp_math(
|
2016-11-13 15:01:11 +08:00
|
|
|
half addrspace(1)* %r,
|
|
|
|
half addrspace(1)* %a,
|
|
|
|
half addrspace(1)* %b,
|
|
|
|
half addrspace(1)* %c) #1 {
|
|
|
|
entry:
|
|
|
|
%a.val = load half, half addrspace(1)* %a
|
|
|
|
%b.val = load half, half addrspace(1)* %b
|
|
|
|
%c.val = load half, half addrspace(1)* %c
|
|
|
|
|
|
|
|
%b.neg = fsub half 0.0, %b.val
|
|
|
|
%t.val = fmul half %a.val, %b.neg
|
|
|
|
%r.val = fadd half %t.val, %c.val
|
|
|
|
|
|
|
|
store half %r.val, half addrspace(1)* %r
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-03-09 09:36:39 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_f16_neg_c_nsz_fp_math:
|
2017-02-03 07:21:23 +08:00
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT_A:v[0-9]+]], v{{[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT_B:v[0-9]+]], v{{[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT_C:v[0-9]+]], v{{[0-9]+}}
|
|
|
|
; SI: v_mad_f32 v{{[0-9]+}}, [[CVT_A]], [[CVT_B]], -[[CVT_C]]
|
2017-02-02 10:27:04 +08:00
|
|
|
|
2016-11-13 15:01:11 +08:00
|
|
|
; VI-NOT: v_mac_f16
|
|
|
|
; VI: v_mad_f16 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}, -v{{[0-9]}}
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_f16_neg_c_nsz_fp_math(
|
2016-11-13 15:01:11 +08:00
|
|
|
half addrspace(1)* %r,
|
|
|
|
half addrspace(1)* %a,
|
|
|
|
half addrspace(1)* %b,
|
|
|
|
half addrspace(1)* %c) #1 {
|
|
|
|
entry:
|
|
|
|
%a.val = load half, half addrspace(1)* %a
|
|
|
|
%b.val = load half, half addrspace(1)* %b
|
|
|
|
%c.val = load half, half addrspace(1)* %c
|
|
|
|
|
|
|
|
%c.neg = fsub half 0.0, %c.val
|
|
|
|
%t.val = fmul half %a.val, %b.val
|
|
|
|
%r.val = fadd half %t.val, %c.neg
|
|
|
|
|
|
|
|
store half %r.val, half addrspace(1)* %r
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-02 10:27:04 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_v2f16:
|
2017-01-25 06:02:15 +08:00
|
|
|
; GCN: {{buffer|flat}}_load_dword v[[A_V2_F16:[0-9]+]]
|
|
|
|
; GCN: {{buffer|flat}}_load_dword v[[B_V2_F16:[0-9]+]]
|
|
|
|
; GCN: {{buffer|flat}}_load_dword v[[C_V2_F16:[0-9]+]]
|
2017-03-16 03:04:26 +08:00
|
|
|
|
2016-11-13 15:01:11 +08:00
|
|
|
; SI: v_cvt_f32_f16_e32 v[[A_F32_0:[0-9]+]], v[[A_V2_F16]]
|
[AMDGPU] Mark s_barrier as having side effects but not accessing memory.
Summary:
This fixes poor scheduling in a function containing a barrier and a few
load instructions.
Without this fix, ScheduleDAGInstrs::buildSchedGraph adds an artificial
edge in the dependency graph from the barrier instruction to the exit
node representing live-out latency, with a latency of about 500 cycles.
Because of this it thinks the critical path through the graph also has
a latency of about 500 cycles. And because of that it does not think
that any of the load instructions are on the critical path, so it
schedules them with no regard for their (80 cycle) latency, which gives
poor results.
Reviewers: arsenm, dstuttard, tpr, nhaehnle
Subscribers: kzhuravl, jvesely, wdng, yaxunl, t-tye, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67218
llvm-svn: 371192
2019-09-06 18:07:28 +08:00
|
|
|
; SI-DAG: v_lshrrev_b32_e32 v[[A_F16_1:[0-9]+]], 16, v[[A_V2_F16]]
|
|
|
|
; SI-DAG: v_cvt_f32_f16_e32 v[[A_F32_1:[0-9]+]], v[[A_F16_1]]
|
|
|
|
|
|
|
|
; SI-DAG: v_lshrrev_b32_e32 v[[B_F16_1:[0-9]+]], 16, v[[B_V2_F16]]
|
|
|
|
; SI-DAG: v_cvt_f32_f16_e32 v[[B_F32_1:[0-9]+]], v[[B_F16_1]]
|
|
|
|
; SI-DAG: v_cvt_f32_f16_e32 v[[B_F32_0:[0-9]+]], v[[B_V2_F16]]
|
|
|
|
|
|
|
|
; SI-DAG: v_lshrrev_b32_e32 v[[C_F16_1:[0-9]+]], 16, v[[C_V2_F16]]
|
|
|
|
; SI-DAG: v_cvt_f32_f16_e32 v[[C_F32_1:[0-9]+]], v[[C_F16_1]]
|
2017-06-04 01:39:47 +08:00
|
|
|
; SI-DAG: v_cvt_f32_f16_e32 v[[C_F32_0:[0-9]+]], v[[C_V2_F16]]
|
[AMDGPU] Mark s_barrier as having side effects but not accessing memory.
Summary:
This fixes poor scheduling in a function containing a barrier and a few
load instructions.
Without this fix, ScheduleDAGInstrs::buildSchedGraph adds an artificial
edge in the dependency graph from the barrier instruction to the exit
node representing live-out latency, with a latency of about 500 cycles.
Because of this it thinks the critical path through the graph also has
a latency of about 500 cycles. And because of that it does not think
that any of the load instructions are on the critical path, so it
schedules them with no regard for their (80 cycle) latency, which gives
poor results.
Reviewers: arsenm, dstuttard, tpr, nhaehnle
Subscribers: kzhuravl, jvesely, wdng, yaxunl, t-tye, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67218
llvm-svn: 371192
2019-09-06 18:07:28 +08:00
|
|
|
|
2017-07-11 03:53:57 +08:00
|
|
|
; SI-DAG: v_mac_f32_e32 v[[C_F32_0]], v[[A_F32_0]], v[[B_F32_0]]
|
2017-03-16 03:04:26 +08:00
|
|
|
; SI-DAG: v_cvt_f16_f32_e32 v[[R_F16_LO:[0-9]+]], v[[C_F32_0]]
|
2017-07-11 03:53:57 +08:00
|
|
|
; SI-DAG: v_mac_f32_e32 v[[C_F32_1]], v[[A_F32_1]], v[[B_F32_1]]
|
2017-03-16 03:04:26 +08:00
|
|
|
; SI-DAG: v_cvt_f16_f32_e32 v[[R_F16_1:[0-9]+]], v[[C_F32_1]]
|
2016-11-13 15:01:11 +08:00
|
|
|
; SI: v_lshlrev_b32_e32 v[[R_F16_HI:[0-9]+]], 16, v[[R_F16_1]]
|
2017-04-01 03:53:03 +08:00
|
|
|
; VI-NOT: and
|
2017-07-11 03:53:57 +08:00
|
|
|
; SI: v_or_b32_e32 v[[R_V2_F16:[0-9]+]], v[[R_F16_LO]], v[[R_F16_HI]]
|
2017-03-16 03:04:26 +08:00
|
|
|
|
2017-06-04 01:39:47 +08:00
|
|
|
; VI-DAG: v_lshrrev_b32_e32 v[[C_F16_1:[0-9]+]], 16, v[[C_V2_F16]]
|
|
|
|
; VI-DAG: v_mac_f16_sdwa v[[C_F16_1]], v[[A_V2_F16]], v[[B_V2_F16]] dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1
|
2017-07-11 03:53:57 +08:00
|
|
|
; VI-DAG: v_mac_f16_e32 v[[C_V2_F16]], v[[A_V2_F16]], v[[B_V2_F16]]
|
2017-06-04 01:39:47 +08:00
|
|
|
; VI-DAG: v_lshlrev_b32_e32 v[[R_F16_HI:[0-9]+]], 16, v[[C_F16_1]]
|
2017-04-01 03:53:03 +08:00
|
|
|
; VI-NOT: and
|
2017-07-11 03:53:57 +08:00
|
|
|
; VI: v_or_b32_e32 v[[R_V2_F16:[0-9]+]], v[[C_V2_F16]], v[[R_F16_HI]]
|
2017-04-01 03:53:03 +08:00
|
|
|
|
2017-01-25 06:02:15 +08:00
|
|
|
; GCN: {{buffer|flat}}_store_dword v[[R_V2_F16]]
|
2016-11-13 15:01:11 +08:00
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_v2f16(
|
2016-11-13 15:01:11 +08:00
|
|
|
<2 x half> addrspace(1)* %r,
|
|
|
|
<2 x half> addrspace(1)* %a,
|
|
|
|
<2 x half> addrspace(1)* %b,
|
|
|
|
<2 x half> addrspace(1)* %c) #0 {
|
|
|
|
entry:
|
|
|
|
%a.val = load <2 x half>, <2 x half> addrspace(1)* %a
|
2017-06-04 01:39:47 +08:00
|
|
|
call void @llvm.amdgcn.s.barrier() #2
|
2016-11-13 15:01:11 +08:00
|
|
|
%b.val = load <2 x half>, <2 x half> addrspace(1)* %b
|
2017-06-04 01:39:47 +08:00
|
|
|
call void @llvm.amdgcn.s.barrier() #2
|
2016-11-13 15:01:11 +08:00
|
|
|
%c.val = load <2 x half>, <2 x half> addrspace(1)* %c
|
|
|
|
|
|
|
|
%t.val = fmul <2 x half> %a.val, %b.val
|
|
|
|
%r.val = fadd <2 x half> %t.val, %c.val
|
|
|
|
|
|
|
|
store <2 x half> %r.val, <2 x half> addrspace(1)* %r
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-02 10:27:04 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_v2f16_same_add:
|
2017-03-16 03:04:26 +08:00
|
|
|
; SI: v_mad_f32 v{{[0-9]}}, v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
|
|
|
|
; SI: v_mac_f32_e32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
|
AMDGPU: Add pass to lower kernel arguments to loads
This replaces most argument uses with loads, but for
now not all.
The code in SelectionDAG for calling convention lowering
is actively harmful for amdgpu_kernel. It attempts to
split the argument types into register legal types, which
results in low quality code for arbitary types. Since
all kernel arguments are passed in memory, we just want the
raw types.
I've tried a couple of methods of mitigating this in SelectionDAG,
but it's easier to just bypass this problem alltogether. It's
possible to hack around the problem in the initial lowering,
but the real problem is the DAG then expects to be able to use
CopyToReg/CopyFromReg for uses of the arguments outside the block.
Exposing the argument loads in the IR also has the advantage
that the LoadStoreVectorizer can merge them.
I'm not sure the best approach to dealing with the IR
argument list is. The patch as-is just leaves the IR arguments
in place, so all the existing code will still compute the same
kernarg size and pointlessly lowers the arguments.
Arguably the frontend should emit kernels with an empty argument
list in the first place. Alternatively a dummy array could be
inserted as a single argument just to reserve space.
This does have some disadvantages. Local pointer kernel arguments can
no longer have AssertZext placed on them as the equivalent !range
metadata is not valid on pointer typed loads. This is mostly bad
for SI which needs to know about the known bits in order to use the
DS instruction offset, so in this case this is not done.
More importantly, this skips noalias arguments since this pass
does not yet convert this to the equivalent !alias.scope and !noalias
metadata. Producing this metadata correctly seems to be tricky,
although this logically is the same as inlining into a function which
doesn't exist. Additionally, exposing these loads to the vectorizer
may result in degraded aliasing information if a pointer load is
merged with another argument load.
I'm also not entirely sure this is preserving the current clover
ABI, although I would greatly prefer if it would stop widening
arguments and match the HSA ABI. As-is I think it is extending
< 4-byte arguments to 4-bytes but doesn't align them to 4-bytes.
llvm-svn: 335650
2018-06-27 03:10:00 +08:00
|
|
|
; SI: v_mad_f32 v{{[0-9]}}, v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
|
2017-03-16 03:04:26 +08:00
|
|
|
; SI: v_mac_f32_e32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
|
2017-04-06 23:03:28 +08:00
|
|
|
|
|
|
|
; VI-DAG: v_mac_f16_sdwa v{{[0-9]}}, v{{[0-9]+}}, v{{[0-9]+}} dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1
|
|
|
|
; VI-DAG: v_mad_f16 v{{[0-9]}}, v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
|
|
|
|
; VI-DAG: v_mac_f16_sdwa v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1
|
|
|
|
; VI-DAG: v_mac_f16_e32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
|
|
|
|
|
2016-11-13 15:01:11 +08:00
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_v2f16_same_add(
|
2016-11-13 15:01:11 +08:00
|
|
|
<2 x half> addrspace(1)* %r0,
|
|
|
|
<2 x half> addrspace(1)* %r1,
|
|
|
|
<2 x half> addrspace(1)* %a,
|
|
|
|
<2 x half> addrspace(1)* %b,
|
|
|
|
<2 x half> addrspace(1)* %c,
|
|
|
|
<2 x half> addrspace(1)* %d,
|
|
|
|
<2 x half> addrspace(1)* %e) #0 {
|
|
|
|
entry:
|
|
|
|
%a.val = load <2 x half>, <2 x half> addrspace(1)* %a
|
|
|
|
%b.val = load <2 x half>, <2 x half> addrspace(1)* %b
|
|
|
|
%c.val = load <2 x half>, <2 x half> addrspace(1)* %c
|
|
|
|
%d.val = load <2 x half>, <2 x half> addrspace(1)* %d
|
|
|
|
%e.val = load <2 x half>, <2 x half> addrspace(1)* %e
|
|
|
|
|
|
|
|
%t0.val = fmul <2 x half> %a.val, %b.val
|
|
|
|
%r0.val = fadd <2 x half> %t0.val, %c.val
|
|
|
|
|
|
|
|
%t1.val = fmul <2 x half> %d.val, %e.val
|
|
|
|
%r1.val = fadd <2 x half> %t1.val, %c.val
|
|
|
|
|
|
|
|
store <2 x half> %r0.val, <2 x half> addrspace(1)* %r0
|
|
|
|
store <2 x half> %r1.val, <2 x half> addrspace(1)* %r1
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-02 10:27:04 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_v2f16_neg_a:
|
2017-02-03 07:21:23 +08:00
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT0:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT1:v[0-9]+]], {{v[0-9]+}}
|
2017-02-02 10:27:04 +08:00
|
|
|
|
AMDGPU: Add pass to lower kernel arguments to loads
This replaces most argument uses with loads, but for
now not all.
The code in SelectionDAG for calling convention lowering
is actively harmful for amdgpu_kernel. It attempts to
split the argument types into register legal types, which
results in low quality code for arbitary types. Since
all kernel arguments are passed in memory, we just want the
raw types.
I've tried a couple of methods of mitigating this in SelectionDAG,
but it's easier to just bypass this problem alltogether. It's
possible to hack around the problem in the initial lowering,
but the real problem is the DAG then expects to be able to use
CopyToReg/CopyFromReg for uses of the arguments outside the block.
Exposing the argument loads in the IR also has the advantage
that the LoadStoreVectorizer can merge them.
I'm not sure the best approach to dealing with the IR
argument list is. The patch as-is just leaves the IR arguments
in place, so all the existing code will still compute the same
kernarg size and pointlessly lowers the arguments.
Arguably the frontend should emit kernels with an empty argument
list in the first place. Alternatively a dummy array could be
inserted as a single argument just to reserve space.
This does have some disadvantages. Local pointer kernel arguments can
no longer have AssertZext placed on them as the equivalent !range
metadata is not valid on pointer typed loads. This is mostly bad
for SI which needs to know about the known bits in order to use the
DS instruction offset, so in this case this is not done.
More importantly, this skips noalias arguments since this pass
does not yet convert this to the equivalent !alias.scope and !noalias
metadata. Producing this metadata correctly seems to be tricky,
although this logically is the same as inlining into a function which
doesn't exist. Additionally, exposing these loads to the vectorizer
may result in degraded aliasing information if a pointer load is
merged with another argument load.
I'm also not entirely sure this is preserving the current clover
ABI, although I would greatly prefer if it would stop widening
arguments and match the HSA ABI. As-is I think it is extending
< 4-byte arguments to 4-bytes but doesn't align them to 4-bytes.
llvm-svn: 335650
2018-06-27 03:10:00 +08:00
|
|
|
; SI: v_mad_f32 v{{[0-9]+}}, -v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
|
|
|
|
; SI: v_mad_f32 v{{[0-9]+}}, -v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
|
2017-02-02 10:27:04 +08:00
|
|
|
|
2016-11-13 15:01:11 +08:00
|
|
|
; VI-NOT: v_mac_f16
|
|
|
|
; VI: v_mad_f16 v{{[0-9]+}}, -v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
|
|
|
|
; VI: v_mad_f16 v{{[0-9]+}}, -v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_v2f16_neg_a(
|
2016-11-13 15:01:11 +08:00
|
|
|
<2 x half> addrspace(1)* %r,
|
|
|
|
<2 x half> addrspace(1)* %a,
|
|
|
|
<2 x half> addrspace(1)* %b,
|
|
|
|
<2 x half> addrspace(1)* %c) #0 {
|
|
|
|
entry:
|
|
|
|
%a.val = load <2 x half>, <2 x half> addrspace(1)* %a
|
|
|
|
%b.val = load <2 x half>, <2 x half> addrspace(1)* %b
|
|
|
|
%c.val = load <2 x half>, <2 x half> addrspace(1)* %c
|
|
|
|
|
|
|
|
%a.neg = fsub <2 x half> <half -0.0, half -0.0>, %a.val
|
|
|
|
%t.val = fmul <2 x half> %a.neg, %b.val
|
|
|
|
%r.val = fadd <2 x half> %t.val, %c.val
|
|
|
|
|
|
|
|
store <2 x half> %r.val, <2 x half> addrspace(1)* %r
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}mac_v2f16_neg_b
|
2017-02-03 07:21:23 +08:00
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT0:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT1:v[0-9]+]], {{v[0-9]+}}
|
AMDGPU: Add pass to lower kernel arguments to loads
This replaces most argument uses with loads, but for
now not all.
The code in SelectionDAG for calling convention lowering
is actively harmful for amdgpu_kernel. It attempts to
split the argument types into register legal types, which
results in low quality code for arbitary types. Since
all kernel arguments are passed in memory, we just want the
raw types.
I've tried a couple of methods of mitigating this in SelectionDAG,
but it's easier to just bypass this problem alltogether. It's
possible to hack around the problem in the initial lowering,
but the real problem is the DAG then expects to be able to use
CopyToReg/CopyFromReg for uses of the arguments outside the block.
Exposing the argument loads in the IR also has the advantage
that the LoadStoreVectorizer can merge them.
I'm not sure the best approach to dealing with the IR
argument list is. The patch as-is just leaves the IR arguments
in place, so all the existing code will still compute the same
kernarg size and pointlessly lowers the arguments.
Arguably the frontend should emit kernels with an empty argument
list in the first place. Alternatively a dummy array could be
inserted as a single argument just to reserve space.
This does have some disadvantages. Local pointer kernel arguments can
no longer have AssertZext placed on them as the equivalent !range
metadata is not valid on pointer typed loads. This is mostly bad
for SI which needs to know about the known bits in order to use the
DS instruction offset, so in this case this is not done.
More importantly, this skips noalias arguments since this pass
does not yet convert this to the equivalent !alias.scope and !noalias
metadata. Producing this metadata correctly seems to be tricky,
although this logically is the same as inlining into a function which
doesn't exist. Additionally, exposing these loads to the vectorizer
may result in degraded aliasing information if a pointer load is
merged with another argument load.
I'm also not entirely sure this is preserving the current clover
ABI, although I would greatly prefer if it would stop widening
arguments and match the HSA ABI. As-is I think it is extending
< 4-byte arguments to 4-bytes but doesn't align them to 4-bytes.
llvm-svn: 335650
2018-06-27 03:10:00 +08:00
|
|
|
; SI: v_mad_f32 v{{[0-9]+}}, -v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
|
|
|
|
; SI: v_mad_f32 v{{[0-9]+}}, -v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
|
2017-02-02 10:27:04 +08:00
|
|
|
|
|
|
|
|
2016-11-13 15:01:11 +08:00
|
|
|
; VI-NOT: v_mac_f16
|
|
|
|
; VI: v_mad_f16 v{{[0-9]+}}, -v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
|
|
|
|
; VI: v_mad_f16 v{{[0-9]+}}, -v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_v2f16_neg_b(
|
2016-11-13 15:01:11 +08:00
|
|
|
<2 x half> addrspace(1)* %r,
|
|
|
|
<2 x half> addrspace(1)* %a,
|
|
|
|
<2 x half> addrspace(1)* %b,
|
|
|
|
<2 x half> addrspace(1)* %c) #0 {
|
|
|
|
entry:
|
|
|
|
%a.val = load <2 x half>, <2 x half> addrspace(1)* %a
|
|
|
|
%b.val = load <2 x half>, <2 x half> addrspace(1)* %b
|
|
|
|
%c.val = load <2 x half>, <2 x half> addrspace(1)* %c
|
|
|
|
|
|
|
|
%b.neg = fsub <2 x half> <half -0.0, half -0.0>, %b.val
|
|
|
|
%t.val = fmul <2 x half> %a.val, %b.neg
|
|
|
|
%r.val = fadd <2 x half> %t.val, %c.val
|
|
|
|
|
|
|
|
store <2 x half> %r.val, <2 x half> addrspace(1)* %r
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-02 10:27:04 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_v2f16_neg_c:
|
2017-02-03 07:21:23 +08:00
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT0:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT1:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT2:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT3:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT4:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT5:v[0-9]+]], {{v[0-9]+}}
|
2017-02-02 10:27:04 +08:00
|
|
|
|
AMDGPU: Add pass to lower kernel arguments to loads
This replaces most argument uses with loads, but for
now not all.
The code in SelectionDAG for calling convention lowering
is actively harmful for amdgpu_kernel. It attempts to
split the argument types into register legal types, which
results in low quality code for arbitary types. Since
all kernel arguments are passed in memory, we just want the
raw types.
I've tried a couple of methods of mitigating this in SelectionDAG,
but it's easier to just bypass this problem alltogether. It's
possible to hack around the problem in the initial lowering,
but the real problem is the DAG then expects to be able to use
CopyToReg/CopyFromReg for uses of the arguments outside the block.
Exposing the argument loads in the IR also has the advantage
that the LoadStoreVectorizer can merge them.
I'm not sure the best approach to dealing with the IR
argument list is. The patch as-is just leaves the IR arguments
in place, so all the existing code will still compute the same
kernarg size and pointlessly lowers the arguments.
Arguably the frontend should emit kernels with an empty argument
list in the first place. Alternatively a dummy array could be
inserted as a single argument just to reserve space.
This does have some disadvantages. Local pointer kernel arguments can
no longer have AssertZext placed on them as the equivalent !range
metadata is not valid on pointer typed loads. This is mostly bad
for SI which needs to know about the known bits in order to use the
DS instruction offset, so in this case this is not done.
More importantly, this skips noalias arguments since this pass
does not yet convert this to the equivalent !alias.scope and !noalias
metadata. Producing this metadata correctly seems to be tricky,
although this logically is the same as inlining into a function which
doesn't exist. Additionally, exposing these loads to the vectorizer
may result in degraded aliasing information if a pointer load is
merged with another argument load.
I'm also not entirely sure this is preserving the current clover
ABI, although I would greatly prefer if it would stop widening
arguments and match the HSA ABI. As-is I think it is extending
< 4-byte arguments to 4-bytes but doesn't align them to 4-bytes.
llvm-svn: 335650
2018-06-27 03:10:00 +08:00
|
|
|
; SI-DAG: v_mad_f32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}, -v{{[0-9]+}}
|
|
|
|
; SI-DAG: v_mad_f32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}, -v{{[0-9]+}}
|
2017-02-02 10:27:04 +08:00
|
|
|
|
2016-11-13 15:01:11 +08:00
|
|
|
; VI-NOT: v_mac_f16
|
|
|
|
; VI: v_mad_f16 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}, -v{{[0-9]+}}
|
|
|
|
; VI: v_mad_f16 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}, -v{{[0-9]+}}
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_v2f16_neg_c(
|
2016-11-13 15:01:11 +08:00
|
|
|
<2 x half> addrspace(1)* %r,
|
|
|
|
<2 x half> addrspace(1)* %a,
|
|
|
|
<2 x half> addrspace(1)* %b,
|
|
|
|
<2 x half> addrspace(1)* %c) #0 {
|
|
|
|
entry:
|
|
|
|
%a.val = load <2 x half>, <2 x half> addrspace(1)* %a
|
|
|
|
%b.val = load <2 x half>, <2 x half> addrspace(1)* %b
|
|
|
|
%c.val = load <2 x half>, <2 x half> addrspace(1)* %c
|
|
|
|
|
|
|
|
%c.neg = fsub <2 x half> <half -0.0, half -0.0>, %c.val
|
|
|
|
%t.val = fmul <2 x half> %a.val, %b.val
|
|
|
|
%r.val = fadd <2 x half> %t.val, %c.neg
|
|
|
|
|
|
|
|
store <2 x half> %r.val, <2 x half> addrspace(1)* %r
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-01-31 00:57:41 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_v2f16_neg_a_safe_fp_math:
|
2017-04-06 23:03:28 +08:00
|
|
|
|
2017-01-31 00:57:41 +08:00
|
|
|
; SI: v_sub_f32_e32 v[[NEG_A0:[0-9]+]], 0, v{{[0-9]+}}
|
|
|
|
; SI: v_sub_f32_e32 v[[NEG_A1:[0-9]+]], 0, v{{[0-9]+}}
|
2017-07-11 03:53:57 +08:00
|
|
|
; SI-DAG: v_mac_f32_e32 v{{[0-9]+}}, v[[NEG_A0]], v{{[0-9]+}}
|
|
|
|
; SI-DAG: v_mac_f32_e32 v{{[0-9]+}}, v[[NEG_A1]], v{{[0-9]+}}
|
2017-04-06 23:03:28 +08:00
|
|
|
|
2017-05-31 00:49:24 +08:00
|
|
|
; VI-DAG: v_mov_b32_e32 [[ZERO:v[0-9]+]], 0
|
|
|
|
; VI-DAG: v_sub_f16_e32 v[[NEG_A1:[0-9]+]], 0, v{{[0-9]+}}
|
|
|
|
; VI-DAG: v_sub_f16_sdwa v[[NEG_A0:[0-9]+]], [[ZERO]], v{{[0-9]+}} dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
|
2017-06-04 01:39:47 +08:00
|
|
|
; VI-DAG: v_mac_f16_sdwa v{{[0-9]+}}, v[[NEG_A0]], v{{[0-9]+}} dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
|
2017-07-11 03:53:57 +08:00
|
|
|
; VI-DAG: v_mac_f16_e32 v{{[0-9]+}}, v[[NEG_A1]], v{{[0-9]+}}
|
2017-04-06 23:03:28 +08:00
|
|
|
|
2016-11-13 15:01:11 +08:00
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_v2f16_neg_a_safe_fp_math(
|
2016-11-13 15:01:11 +08:00
|
|
|
<2 x half> addrspace(1)* %r,
|
|
|
|
<2 x half> addrspace(1)* %a,
|
|
|
|
<2 x half> addrspace(1)* %b,
|
|
|
|
<2 x half> addrspace(1)* %c) #0 {
|
|
|
|
entry:
|
|
|
|
%a.val = load <2 x half>, <2 x half> addrspace(1)* %a
|
|
|
|
%b.val = load <2 x half>, <2 x half> addrspace(1)* %b
|
|
|
|
%c.val = load <2 x half>, <2 x half> addrspace(1)* %c
|
|
|
|
|
|
|
|
%a.neg = fsub <2 x half> <half 0.0, half 0.0>, %a.val
|
|
|
|
%t.val = fmul <2 x half> %a.neg, %b.val
|
|
|
|
%r.val = fadd <2 x half> %t.val, %c.val
|
|
|
|
|
|
|
|
store <2 x half> %r.val, <2 x half> addrspace(1)* %r
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-02 10:27:04 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_v2f16_neg_b_safe_fp_math:
|
2017-04-06 23:03:28 +08:00
|
|
|
|
2017-01-31 00:57:41 +08:00
|
|
|
; SI: v_sub_f32_e32 v[[NEG_A0:[0-9]+]], 0, v{{[0-9]+}}
|
|
|
|
; SI: v_sub_f32_e32 v[[NEG_A1:[0-9]+]], 0, v{{[0-9]+}}
|
2017-07-11 03:53:57 +08:00
|
|
|
; SI-DAG: v_mac_f32_e32 v{{[0-9]+}}, v{{[0-9]+}}, v[[NEG_A0]]
|
|
|
|
; SI-DAG: v_mac_f32_e32 v{{[0-9]+}}, v{{[0-9]+}}, v[[NEG_A1]]
|
2017-04-06 23:03:28 +08:00
|
|
|
|
2017-05-31 00:49:24 +08:00
|
|
|
; VI: v_mov_b32_e32 [[ZERO:v[0-9]+]], 0
|
2016-11-13 15:01:11 +08:00
|
|
|
; VI: v_sub_f16_e32 v[[NEG_A1:[0-9]+]], 0, v{{[0-9]+}}
|
2017-05-31 00:49:24 +08:00
|
|
|
; VI: v_sub_f16_sdwa v[[NEG_A0:[0-9]+]], [[ZERO]], v{{[0-9]+}} dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
|
2017-06-04 01:39:47 +08:00
|
|
|
; VI-DAG: v_mac_f16_sdwa v{{[0-9]+}}, v{{[0-9]+}}, v[[NEG_A0]] dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:DWORD
|
2017-07-11 03:53:57 +08:00
|
|
|
; VI-DAG: v_mac_f16_e32 v{{[0-9]+}}, v{{[0-9]+}}, v[[NEG_A1]]
|
2017-04-06 23:03:28 +08:00
|
|
|
|
2016-11-13 15:01:11 +08:00
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_v2f16_neg_b_safe_fp_math(
|
2016-11-13 15:01:11 +08:00
|
|
|
<2 x half> addrspace(1)* %r,
|
|
|
|
<2 x half> addrspace(1)* %a,
|
|
|
|
<2 x half> addrspace(1)* %b,
|
|
|
|
<2 x half> addrspace(1)* %c) #0 {
|
|
|
|
entry:
|
|
|
|
%a.val = load <2 x half>, <2 x half> addrspace(1)* %a
|
|
|
|
%b.val = load <2 x half>, <2 x half> addrspace(1)* %b
|
|
|
|
%c.val = load <2 x half>, <2 x half> addrspace(1)* %c
|
|
|
|
|
|
|
|
%b.neg = fsub <2 x half> <half 0.0, half 0.0>, %b.val
|
|
|
|
%t.val = fmul <2 x half> %a.val, %b.neg
|
|
|
|
%r.val = fadd <2 x half> %t.val, %c.val
|
|
|
|
|
|
|
|
store <2 x half> %r.val, <2 x half> addrspace(1)* %r
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-02 10:27:04 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_v2f16_neg_c_safe_fp_math:
|
2017-04-06 23:03:28 +08:00
|
|
|
|
2017-01-31 00:57:41 +08:00
|
|
|
; SI: v_sub_f32_e32 v[[NEG_A0:[0-9]+]], 0, v{{[0-9]+}}
|
|
|
|
; SI: v_sub_f32_e32 v[[NEG_A1:[0-9]+]], 0, v{{[0-9]+}}
|
2017-03-16 03:04:26 +08:00
|
|
|
; SI-DAG: v_mac_f32_e32 v[[NEG_A0]], v{{[0-9]+}}, v{{[0-9]+}}
|
|
|
|
; SI-DAG: v_mac_f32_e32 v[[NEG_A1]], v{{[0-9]+}}, v{{[0-9]+}}
|
2017-04-06 23:03:28 +08:00
|
|
|
|
2017-05-31 00:49:24 +08:00
|
|
|
; VI: v_mov_b32_e32 [[ZERO:v[0-9]+]], 0
|
2016-11-13 15:01:11 +08:00
|
|
|
; VI: v_sub_f16_e32 v[[NEG_A1:[0-9]+]], 0, v{{[0-9]+}}
|
2017-05-31 00:49:24 +08:00
|
|
|
; VI: v_sub_f16_sdwa v[[NEG_A0:[0-9]+]], [[ZERO]], v{{[0-9]+}} dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
|
2017-04-06 23:03:28 +08:00
|
|
|
; VI-DAG: v_mac_f16_sdwa v[[NEG_A0]], v{{[0-9]+}}, v{{[0-9]+}} dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1
|
|
|
|
; VI-DAG: v_mac_f16_e32 v[[NEG_A1]], v{{[0-9]+}}, v{{[0-9]+}}
|
|
|
|
|
2016-11-13 15:01:11 +08:00
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_v2f16_neg_c_safe_fp_math(
|
2016-11-13 15:01:11 +08:00
|
|
|
<2 x half> addrspace(1)* %r,
|
|
|
|
<2 x half> addrspace(1)* %a,
|
|
|
|
<2 x half> addrspace(1)* %b,
|
|
|
|
<2 x half> addrspace(1)* %c) #0 {
|
|
|
|
entry:
|
|
|
|
%a.val = load <2 x half>, <2 x half> addrspace(1)* %a
|
|
|
|
%b.val = load <2 x half>, <2 x half> addrspace(1)* %b
|
|
|
|
%c.val = load <2 x half>, <2 x half> addrspace(1)* %c
|
|
|
|
|
|
|
|
%c.neg = fsub <2 x half> <half 0.0, half 0.0>, %c.val
|
|
|
|
%t.val = fmul <2 x half> %a.val, %b.val
|
|
|
|
%r.val = fadd <2 x half> %t.val, %c.neg
|
|
|
|
|
|
|
|
store <2 x half> %r.val, <2 x half> addrspace(1)* %r
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-03-09 09:36:39 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_v2f16_neg_a_nsz_fp_math:
|
2017-02-03 07:21:23 +08:00
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT0:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT1:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT2:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT3:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT4:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT5:v[0-9]+]], {{v[0-9]+}}
|
2017-02-02 10:27:04 +08:00
|
|
|
|
2017-02-03 07:21:23 +08:00
|
|
|
; SI-DAG: v_mad_f32 v{{[0-9]+}}, -v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
|
|
|
|
; SI-DAG: v_mad_f32 v{{[0-9]+}}, -v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
|
2017-02-02 10:27:04 +08:00
|
|
|
|
2016-11-13 15:01:11 +08:00
|
|
|
; VI-NOT: v_mac_f16
|
|
|
|
; VI: v_mad_f16 v{{[0-9]+}}, -v{{[0-9]+}}, v{{[0-9]+}}, v{{[-0-9]}}
|
|
|
|
; VI: v_mad_f16 v{{[0-9]+}}, -v{{[0-9]+}}, v{{[0-9]+}}, v{{[-0-9]}}
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_v2f16_neg_a_nsz_fp_math(
|
2016-11-13 15:01:11 +08:00
|
|
|
<2 x half> addrspace(1)* %r,
|
|
|
|
<2 x half> addrspace(1)* %a,
|
|
|
|
<2 x half> addrspace(1)* %b,
|
|
|
|
<2 x half> addrspace(1)* %c) #1 {
|
|
|
|
entry:
|
|
|
|
%a.val = load <2 x half>, <2 x half> addrspace(1)* %a
|
|
|
|
%b.val = load <2 x half>, <2 x half> addrspace(1)* %b
|
|
|
|
%c.val = load <2 x half>, <2 x half> addrspace(1)* %c
|
|
|
|
|
|
|
|
%a.neg = fsub <2 x half> <half 0.0, half 0.0>, %a.val
|
|
|
|
%t.val = fmul <2 x half> %a.neg, %b.val
|
|
|
|
%r.val = fadd <2 x half> %t.val, %c.val
|
|
|
|
|
|
|
|
store <2 x half> %r.val, <2 x half> addrspace(1)* %r
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-03-09 09:36:39 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_v2f16_neg_b_nsz_fp_math:
|
2017-02-03 07:21:23 +08:00
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT0:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT1:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT2:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT3:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT4:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT5:v[0-9]+]], {{v[0-9]+}}
|
2017-02-02 10:27:04 +08:00
|
|
|
|
2017-02-03 07:21:23 +08:00
|
|
|
; SI-DAG: v_mad_f32 v{{[0-9]+}}, -v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
|
|
|
|
; SI-DAG: v_mad_f32 v{{[0-9]+}}, -v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}
|
2017-02-02 10:27:04 +08:00
|
|
|
|
2016-11-13 15:01:11 +08:00
|
|
|
; VI-NOT: v_mac_f16
|
|
|
|
; VI: v_mad_f16 v{{[0-9]+}}, -v{{[0-9]+}}, v{{[0-9]+}}, v{{[-0-9]}}
|
|
|
|
; VI: v_mad_f16 v{{[0-9]+}}, -v{{[0-9]+}}, v{{[0-9]+}}, v{{[-0-9]}}
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_v2f16_neg_b_nsz_fp_math(
|
2016-11-13 15:01:11 +08:00
|
|
|
<2 x half> addrspace(1)* %r,
|
|
|
|
<2 x half> addrspace(1)* %a,
|
|
|
|
<2 x half> addrspace(1)* %b,
|
|
|
|
<2 x half> addrspace(1)* %c) #1 {
|
|
|
|
entry:
|
|
|
|
%a.val = load <2 x half>, <2 x half> addrspace(1)* %a
|
|
|
|
%b.val = load <2 x half>, <2 x half> addrspace(1)* %b
|
|
|
|
%c.val = load <2 x half>, <2 x half> addrspace(1)* %c
|
|
|
|
|
|
|
|
%b.neg = fsub <2 x half> <half 0.0, half 0.0>, %b.val
|
|
|
|
%t.val = fmul <2 x half> %a.val, %b.neg
|
|
|
|
%r.val = fadd <2 x half> %t.val, %c.val
|
|
|
|
|
|
|
|
store <2 x half> %r.val, <2 x half> addrspace(1)* %r
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-03-09 09:36:39 +08:00
|
|
|
; GCN-LABEL: {{^}}mac_v2f16_neg_c_nsz_fp_math:
|
2017-02-03 07:21:23 +08:00
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT0:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT1:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT2:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT3:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT4:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
; SI: v_cvt_f32_f16_e32 [[CVT5:v[0-9]+]], {{v[0-9]+}}
|
|
|
|
|
|
|
|
; SI-DAG: v_mad_f32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}, -v{{[0-9]+}}
|
|
|
|
; SI-DAG: v_mad_f32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}, -v{{[0-9]+}}
|
2017-02-02 10:27:04 +08:00
|
|
|
|
2016-11-13 15:01:11 +08:00
|
|
|
; VI-NOT: v_mac_f16
|
|
|
|
; VI: v_mad_f16 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}, -v{{[-0-9]}}
|
|
|
|
; VI: v_mad_f16 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}, -v{{[-0-9]}}
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mac_v2f16_neg_c_nsz_fp_math(
|
2016-11-13 15:01:11 +08:00
|
|
|
<2 x half> addrspace(1)* %r,
|
|
|
|
<2 x half> addrspace(1)* %a,
|
|
|
|
<2 x half> addrspace(1)* %b,
|
|
|
|
<2 x half> addrspace(1)* %c) #1 {
|
|
|
|
entry:
|
|
|
|
%a.val = load <2 x half>, <2 x half> addrspace(1)* %a
|
|
|
|
%b.val = load <2 x half>, <2 x half> addrspace(1)* %b
|
|
|
|
%c.val = load <2 x half>, <2 x half> addrspace(1)* %c
|
|
|
|
|
|
|
|
%c.neg = fsub <2 x half> <half 0.0, half 0.0>, %c.val
|
|
|
|
%t.val = fmul <2 x half> %a.val, %b.val
|
|
|
|
%r.val = fadd <2 x half> %t.val, %c.neg
|
|
|
|
|
|
|
|
store <2 x half> %r.val, <2 x half> addrspace(1)* %r
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-06-04 01:39:47 +08:00
|
|
|
declare void @llvm.amdgcn.s.barrier() #2
|
|
|
|
|
2017-03-09 09:36:39 +08:00
|
|
|
attributes #0 = { nounwind "no-signed-zeros-fp-math"="false" }
|
|
|
|
attributes #1 = { nounwind "no-signed-zeros-fp-math"="true" }
|
2017-06-04 01:39:47 +08:00
|
|
|
attributes #2 = { nounwind convergent }
|