2021-01-06 06:37:29 +08:00
|
|
|
; RUN: llc -amdgpu-scalarize-global-loads=false -verify-machineinstrs -mcpu=tahiti -denormal-fp-math-f32=preserve-sign -mattr=+fast-fmaf -fp-contract=on < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GCN-FLUSH,GCN-FLUSH-MAD,SI %s
|
|
|
|
; RUN: llc -amdgpu-scalarize-global-loads=false -verify-machineinstrs -mcpu=tahiti -denormal-fp-math-f32=ieee -mattr=+fast-fmaf -fp-contract=on < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GCN-DENORM-STRICT,SI-DENORM,GCN-DENORM-FASTFMA,SI %s
|
|
|
|
; RUN: llc -amdgpu-scalarize-global-loads=false -verify-machineinstrs -mcpu=verde -denormal-fp-math-f32=preserve-sign -mattr=-fast-fmaf -fp-contract=on < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GCN-FLUSH,GCN-FLUSH-MAD,SI-FLUSH,SI %s
|
|
|
|
; RUN: llc -amdgpu-scalarize-global-loads=false -verify-machineinstrs -mcpu=verde -denormal-fp-math-f32=ieee -mattr=-fast-fmaf -fp-contract=on < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GCN-DENORM-STRICT,SI-DENORM,GCN-DENORM-SLOWFMA,SI %s
|
2018-05-01 03:08:16 +08:00
|
|
|
|
2021-01-06 06:37:29 +08:00
|
|
|
; RUN: llc -amdgpu-scalarize-global-loads=false -verify-machineinstrs -mcpu=tahiti -denormal-fp-math-f32=preserve-sign -mattr=+fast-fmaf -fp-contract=fast < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GCN-FLUSH,GCN-FLUSH-MAD,SI-FLUSH,SI %s
|
|
|
|
; RUN: llc -amdgpu-scalarize-global-loads=false -verify-machineinstrs -mcpu=tahiti -denormal-fp-math-f32=ieee -mattr=+fast-fmaf -fp-contract=fast < %s | FileCheck -enable-var-scope -check-prefixes=GCN,SI-DENORM,GCN-DENORM-FASTFMA,GCN-DENORM-FASTFMA-CONTRACT,SI %s
|
|
|
|
; RUN: llc -amdgpu-scalarize-global-loads=false -verify-machineinstrs -mcpu=verde -denormal-fp-math-f32=preserve-sign -mattr=-fast-fmaf -fp-contract=fast < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GCN-FLUSH,GCN-FLUSH-MAD,SI-FLUSH,SI %s
|
|
|
|
; RUN: llc -amdgpu-scalarize-global-loads=false -verify-machineinstrs -mcpu=verde -denormal-fp-math-f32=ieee -mattr=-fast-fmaf -fp-contract=fast < %s | FileCheck -enable-var-scope -check-prefixes=GCN,SI-DENORM,GCN-DENORM-SLOWFMA,GCN-DENORM-SLOWFMA-CONTRACT,SI %s
|
2018-05-01 03:08:16 +08:00
|
|
|
|
|
|
|
|
2021-01-06 06:37:29 +08:00
|
|
|
; RUN: llc -amdgpu-scalarize-global-loads=false -verify-machineinstrs -mcpu=gfx900 -denormal-fp-math-f32=preserve-sign -fp-contract=on < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GCN-FLUSH,GCN-FLUSH-MAD %s
|
|
|
|
; RUN: llc -amdgpu-scalarize-global-loads=false -verify-machineinstrs -mcpu=gfx900 -denormal-fp-math-f32=ieee -fp-contract=on < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GCN-DENORM-STRICT,GCN-DENORM-FASTFMA %s
|
2018-05-01 03:08:16 +08:00
|
|
|
|
2021-01-06 06:37:29 +08:00
|
|
|
; RUN: llc -amdgpu-scalarize-global-loads=false -verify-machineinstrs -mcpu=gfx906 -denormal-fp-math-f32=preserve-sign -fp-contract=on < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GCN-FLUSH,GCN-FLUSH-FMAC %s
|
2018-05-01 03:08:16 +08:00
|
|
|
|
|
|
|
; FIXME: Should probably test this, but sometimes selecting fmac is painful to match.
|
2021-01-06 06:37:29 +08:00
|
|
|
; XUN: llc -amdgpu-scalarize-global-loads=false -verify-machineinstrs -mcpu=gfx906 -denormal-fp-math-f32=ieee -fp-contract=on < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GCN-DENORM-STRICT,GCN-DENORM-FASTFMA %s
|
2016-12-22 11:55:35 +08:00
|
|
|
|
2021-01-06 06:37:29 +08:00
|
|
|
; RUN: llc -amdgpu-scalarize-global-loads=false -verify-machineinstrs -mcpu=gfx1030 -denormal-fp-math-f32=preserve-sign -mattr=+mad-mac-f32-insts -fp-contract=on < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GCN-FLUSH,GCN-FLUSH-FMAC %s
|
|
|
|
; RUN: llc -amdgpu-scalarize-global-loads=false -verify-machineinstrs -mcpu=gfx1030 -denormal-fp-math-f32=ieee -mattr=+mad-mac-f32-insts -fp-contract=on < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GCN-DENORM-STRICT %s
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; Test all permutations of: fp32 denormals, fast fp contract, fp contract enabled for fmuladd, fmaf fast/slow.
|
|
|
|
|
|
|
|
target triple = "amdgcn--"
|
|
|
|
|
|
|
|
|
|
|
|
declare i32 @llvm.amdgcn.workitem.id.x() #1
|
|
|
|
declare float @llvm.fmuladd.f32(float, float, float) #1
|
|
|
|
declare half @llvm.fmuladd.f16(half, half, half) #1
|
|
|
|
declare float @llvm.fabs.f32(float) #1
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}fmuladd_f32:
|
2018-05-01 03:08:16 +08:00
|
|
|
; GCN-FLUSH-MAD: v_mac_f32_e32 {{v[0-9]+, v[0-9]+, v[0-9]+}}
|
|
|
|
; GCN-FLUSH-FMAC: v_fmac_f32_e32 {{v[0-9]+, v[0-9]+, v[0-9]+}}
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; GCN-DENORM-FASTFMA: v_fma_f32 {{v[0-9]+, v[0-9]+, v[0-9]+}}
|
|
|
|
|
|
|
|
; GCN-DENORM-SLOWFMA: v_mul_f32_e32 {{v[0-9]+, v[0-9]+, v[0-9]+}}
|
|
|
|
; GCN-DENORM-SLOWFMA: v_add_f32_e32 {{v[0-9]+, v[0-9]+, v[0-9]+}}
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @fmuladd_f32(float addrspace(1)* %out, float addrspace(1)* %in1,
|
2016-12-22 11:55:35 +08:00
|
|
|
float addrspace(1)* %in2, float addrspace(1)* %in3) #0 {
|
|
|
|
%r0 = load float, float addrspace(1)* %in1
|
|
|
|
%r1 = load float, float addrspace(1)* %in2
|
|
|
|
%r2 = load float, float addrspace(1)* %in3
|
|
|
|
%r3 = tail call float @llvm.fmuladd.f32(float %r0, float %r1, float %r2)
|
|
|
|
store float %r3, float addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}fmul_fadd_f32:
|
|
|
|
; GCN-FLUSH: v_mac_f32
|
|
|
|
|
|
|
|
; GCN-DENORM-FASTFMA-CONTRACT: v_fma_f32
|
|
|
|
|
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_mul_f32_e32
|
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_add_f32_e32
|
|
|
|
|
|
|
|
; GCN-DENORM-STRICT: v_mul_f32_e32
|
|
|
|
; GCN-DENORM-STRICT: v_add_f32_e32
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @fmul_fadd_f32(float addrspace(1)* %out, float addrspace(1)* %in1,
|
2016-12-22 11:55:35 +08:00
|
|
|
float addrspace(1)* %in2, float addrspace(1)* %in3) #0 {
|
|
|
|
%r0 = load volatile float, float addrspace(1)* %in1
|
|
|
|
%r1 = load volatile float, float addrspace(1)* %in2
|
|
|
|
%r2 = load volatile float, float addrspace(1)* %in3
|
|
|
|
%mul = fmul float %r0, %r1
|
|
|
|
%add = fadd float %mul, %r2
|
|
|
|
store float %add, float addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2020-07-30 09:12:17 +08:00
|
|
|
; GCN-LABEL: {{^}}fmul_fadd_contract_f32:
|
|
|
|
; GCN-FLUSH-FMAC: v_fmac_f32_e32
|
|
|
|
|
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_mul_f32_e32
|
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_add_f32_e32
|
|
|
|
|
|
|
|
; GCN-DENORM-FASTFMA: v_fma_f32
|
|
|
|
define amdgpu_kernel void @fmul_fadd_contract_f32(float addrspace(1)* %out, float addrspace(1)* %in1,
|
|
|
|
float addrspace(1)* %in2, float addrspace(1)* %in3) #0 {
|
|
|
|
%r0 = load volatile float, float addrspace(1)* %in1
|
|
|
|
%r1 = load volatile float, float addrspace(1)* %in2
|
|
|
|
%r2 = load volatile float, float addrspace(1)* %in3
|
[DAGCombine] reassoc flag shouldn't enable contract
According to IR LangRef, the FMF flag:
contract
Allow floating-point contraction (e.g. fusing a multiply followed by an
addition into a fused multiply-and-add).
reassoc
Allow reassociation transformations for floating-point instructions.
This may dramatically change results in floating-point.
My understanding is that these two flags shouldn't imply each other,
as we might have a SDNode that can be reassociated with others, but
not contractble.
eg: We may want following fmul/fad/fsub to freely reassoc, but don't
want fma being generated here.
%F = fmul reassoc double %A, %B ; <double> [#uses=1]
%G = fmul reassoc double %C, %D ; <double> [#uses=1]
%H = fadd reassoc double %F, %G ; <double> [#uses=1]
%I = fsub reassoc double %H, %E ; <double> [#uses=1]
Before https://reviews.llvm.org/D45710, `reassoc` flag actually
did not imply isContratable either.
The current implementation also only check the flag in fadd node,
ignoring fmul node, this patch update that as well.
Reviewed By: spatel, qiucf
Differential Revision: https://reviews.llvm.org/D104247
2021-06-22 03:25:40 +08:00
|
|
|
%mul = fmul contract float %r0, %r1
|
2020-07-30 09:12:17 +08:00
|
|
|
%add = fadd contract float %mul, %r2
|
|
|
|
store float %add, float addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-12-22 11:55:35 +08:00
|
|
|
; GCN-LABEL: {{^}}fmuladd_2.0_a_b_f32
|
2018-05-01 03:08:16 +08:00
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[R1:v[0-9]+]],
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[R2:v[0-9]+]],
|
2016-12-22 11:55:35 +08:00
|
|
|
|
2018-05-01 03:08:16 +08:00
|
|
|
; GCN-FLUSH-MAD: v_mac_f32_e32 [[R2]], 2.0, [[R1]]
|
|
|
|
; GCN-FLUSH-FMAC: v_fmac_f32_e32 [[R2]], 2.0, [[R1]]
|
2016-12-22 11:55:35 +08:00
|
|
|
; SI-FLUSH: buffer_store_dword [[R2]]
|
|
|
|
; VI-FLUSH: flat_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[R2]]
|
|
|
|
|
|
|
|
; GCN-DENORM-FASTFMA: v_fma_f32 [[RESULT:v[0-9]+]], [[R1]], 2.0, [[R2]]
|
|
|
|
|
|
|
|
; GCN-DENORM-SLOWFMA: v_add_f32_e32 [[TMP:v[0-9]+]], [[R1]], [[R1]]
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-SLOWFMA: v_add_f32_e32 [[RESULT:v[0-9]+]], [[TMP]], [[R2]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
2020-04-03 06:28:32 +08:00
|
|
|
; SI-DENORM: buffer_store_dword [[RESULT]]
|
2016-12-22 11:55:35 +08:00
|
|
|
; VI-DENORM: flat_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @fmuladd_2.0_a_b_f32(float addrspace(1)* %out, float addrspace(1)* %in) #0 {
|
2016-12-22 11:55:35 +08:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%gep.0 = getelementptr float, float addrspace(1)* %out, i32 %tid
|
|
|
|
%gep.1 = getelementptr float, float addrspace(1)* %gep.0, i32 1
|
|
|
|
%gep.out = getelementptr float, float addrspace(1)* %out, i32 %tid
|
|
|
|
|
|
|
|
%r1 = load volatile float, float addrspace(1)* %gep.0
|
|
|
|
%r2 = load volatile float, float addrspace(1)* %gep.1
|
|
|
|
|
|
|
|
%r3 = tail call float @llvm.fmuladd.f32(float 2.0, float %r1, float %r2)
|
|
|
|
store float %r3, float addrspace(1)* %gep.out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}fmuladd_a_2.0_b_f32
|
2018-05-01 03:08:16 +08:00
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[R1:v[0-9]+]],
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[R2:v[0-9]+]],
|
|
|
|
|
|
|
|
; GCN-FLUSH-MAD: v_mac_f32_e32 [[R2]], 2.0, [[R1]]
|
|
|
|
; GCN-FLUSH-FMAC: v_fmac_f32_e32 [[R2]], 2.0, [[R1]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; SI-FLUSH: buffer_store_dword [[R2]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI-FLUSH: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[R2]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; GCN-DENORM-FASTFMA: v_fma_f32 [[RESULT:v[0-9]+]], [[R1]], 2.0, [[R2]]
|
|
|
|
|
|
|
|
; GCN-DENORM-SLOWFMA: v_add_f32_e32 [[TMP:v[0-9]+]], [[R1]], [[R1]]
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-SLOWFMA: v_add_f32_e32 [[RESULT:v[0-9]+]], [[TMP]], [[R2]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; SI-DENORM: buffer_store_dword [[RESULT]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI-DENORM: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @fmuladd_a_2.0_b_f32(float addrspace(1)* %out, float addrspace(1)* %in) #0 {
|
2016-12-22 11:55:35 +08:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%gep.0 = getelementptr float, float addrspace(1)* %out, i32 %tid
|
|
|
|
%gep.1 = getelementptr float, float addrspace(1)* %gep.0, i32 1
|
|
|
|
%gep.out = getelementptr float, float addrspace(1)* %out, i32 %tid
|
|
|
|
|
|
|
|
%r1 = load volatile float, float addrspace(1)* %gep.0
|
|
|
|
%r2 = load volatile float, float addrspace(1)* %gep.1
|
|
|
|
|
|
|
|
%r3 = tail call float @llvm.fmuladd.f32(float %r1, float 2.0, float %r2)
|
|
|
|
store float %r3, float addrspace(1)* %gep.out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}fadd_a_a_b_f32:
|
2018-05-01 03:08:16 +08:00
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[R1:v[0-9]+]],
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[R2:v[0-9]+]],
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; GCN-FLUSH: v_mac_f32_e32 [[R2]], 2.0, [[R1]]
|
2018-05-01 03:08:16 +08:00
|
|
|
|
2016-12-22 11:55:35 +08:00
|
|
|
; SI-FLUSH: buffer_store_dword [[R2]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI-FLUSH: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[R2]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; GCN-DENORM-FASTFMA-CONTRACT: v_fma_f32 [[RESULT:v[0-9]+]], [[R1]], 2.0, [[R2]]
|
|
|
|
|
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_add_f32_e32 [[TMP:v[0-9]+]], [[R1]], [[R1]]
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_add_f32_e32 [[RESULT:v[0-9]+]], [[TMP]], [[R2]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; GCN-DENORM-STRICT: v_add_f32_e32 [[TMP:v[0-9]+]], [[R1]], [[R1]]
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-STRICT: v_add_f32_e32 [[RESULT:v[0-9]+]], [[TMP]], [[R2]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; SI-DENORM: buffer_store_dword [[RESULT]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI-DENORM: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @fadd_a_a_b_f32(float addrspace(1)* %out,
|
2016-12-22 11:55:35 +08:00
|
|
|
float addrspace(1)* %in1,
|
|
|
|
float addrspace(1)* %in2) #0 {
|
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%gep.0 = getelementptr float, float addrspace(1)* %out, i32 %tid
|
|
|
|
%gep.1 = getelementptr float, float addrspace(1)* %gep.0, i32 1
|
|
|
|
%gep.out = getelementptr float, float addrspace(1)* %out, i32 %tid
|
|
|
|
|
|
|
|
%r0 = load volatile float, float addrspace(1)* %gep.0
|
|
|
|
%r1 = load volatile float, float addrspace(1)* %gep.1
|
|
|
|
|
|
|
|
%add.0 = fadd float %r0, %r0
|
|
|
|
%add.1 = fadd float %add.0, %r1
|
|
|
|
store float %add.1, float addrspace(1)* %gep.out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}fadd_b_a_a_f32:
|
2018-05-01 03:08:16 +08:00
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[R1:v[0-9]+]],
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[R2:v[0-9]+]],
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; GCN-FLUSH: v_mac_f32_e32 [[R2]], 2.0, [[R1]]
|
2018-05-01 03:08:16 +08:00
|
|
|
|
2016-12-22 11:55:35 +08:00
|
|
|
; SI-FLUSH: buffer_store_dword [[R2]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI-FLUSH: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[R2]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; GCN-DENORM-FASTFMA-CONTRACT: v_fma_f32 [[RESULT:v[0-9]+]], [[R1]], 2.0, [[R2]]
|
|
|
|
|
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_add_f32_e32 [[TMP:v[0-9]+]], [[R1]], [[R1]]
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_add_f32_e32 [[RESULT:v[0-9]+]], [[R2]], [[TMP]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; GCN-DENORM-STRICT: v_add_f32_e32 [[TMP:v[0-9]+]], [[R1]], [[R1]]
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-STRICT: v_add_f32_e32 [[RESULT:v[0-9]+]], [[R2]], [[TMP]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; SI-DENORM: buffer_store_dword [[RESULT]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI-DENORM: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @fadd_b_a_a_f32(float addrspace(1)* %out,
|
2016-12-22 11:55:35 +08:00
|
|
|
float addrspace(1)* %in1,
|
|
|
|
float addrspace(1)* %in2) #0 {
|
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%gep.0 = getelementptr float, float addrspace(1)* %out, i32 %tid
|
|
|
|
%gep.1 = getelementptr float, float addrspace(1)* %gep.0, i32 1
|
|
|
|
%gep.out = getelementptr float, float addrspace(1)* %out, i32 %tid
|
|
|
|
|
|
|
|
%r0 = load volatile float, float addrspace(1)* %gep.0
|
|
|
|
%r1 = load volatile float, float addrspace(1)* %gep.1
|
|
|
|
|
|
|
|
%add.0 = fadd float %r0, %r0
|
|
|
|
%add.1 = fadd float %r1, %add.0
|
|
|
|
store float %add.1, float addrspace(1)* %gep.out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}fmuladd_neg_2.0_a_b_f32
|
2018-05-01 03:08:16 +08:00
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[R1:v[0-9]+]],
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[R2:v[0-9]+]],
|
|
|
|
; GCN-FLUSH-MAD: v_mac_f32_e32 [[R2]], -2.0, [[R1]]
|
|
|
|
; GCN-FLUSH-FMAC: v_fmac_f32_e32 [[R2]], -2.0, [[R1]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; GCN-DENORM-FASTFMA: v_fma_f32 [[RESULT:v[0-9]+]], [[R1]], -2.0, [[R2]]
|
|
|
|
|
2017-05-04 22:14:44 +08:00
|
|
|
; GCN-DENORM-SLOWFMA: v_add_f32_e32 [[TMP:v[0-9]+]], [[R1]], [[R1]]
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-SLOWFMA: v_sub_f32_e32 [[RESULT:v[0-9]+]], [[R2]], [[TMP]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; SI-DENORM: buffer_store_dword [[RESULT]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI-DENORM: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @fmuladd_neg_2.0_a_b_f32(float addrspace(1)* %out, float addrspace(1)* %in) #0 {
|
2016-12-22 11:55:35 +08:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%gep.0 = getelementptr float, float addrspace(1)* %out, i32 %tid
|
|
|
|
%gep.1 = getelementptr float, float addrspace(1)* %gep.0, i32 1
|
|
|
|
%gep.out = getelementptr float, float addrspace(1)* %out, i32 %tid
|
|
|
|
|
|
|
|
%r1 = load volatile float, float addrspace(1)* %gep.0
|
|
|
|
%r2 = load volatile float, float addrspace(1)* %gep.1
|
|
|
|
|
|
|
|
%r3 = tail call float @llvm.fmuladd.f32(float -2.0, float %r1, float %r2)
|
|
|
|
store float %r3, float addrspace(1)* %gep.out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2018-05-01 03:08:16 +08:00
|
|
|
; XXX
|
2016-12-22 11:55:35 +08:00
|
|
|
; GCN-LABEL: {{^}}fmuladd_neg_2.0_neg_a_b_f32
|
2018-05-01 03:08:16 +08:00
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[R1:v[0-9]+]],
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[R2:v[0-9]+]],
|
|
|
|
|
|
|
|
; GCN-FLUSH-MAD: v_mac_f32_e32 [[R2]], 2.0, [[R1]]
|
|
|
|
; GCN-FLUSH-FMAC: v_fmac_f32_e32 [[R2]], 2.0, [[R1]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; SI-FLUSH: buffer_store_dword [[R2]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI-FLUSH: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[R2]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
2017-10-27 17:06:07 +08:00
|
|
|
; GCN-DENORM-FASTFMA: v_fma_f32 [[RESULT:v[0-9]+]], [[R1]], 2.0, [[R2]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; GCN-DENORM-SLOWFMA: v_add_f32_e32 [[TMP:v[0-9]+]], [[R1]], [[R1]]
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-SLOWFMA: v_add_f32_e32 [[RESULT:v[0-9]+]], [[R2]], [[TMP]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; SI-DENORM: buffer_store_dword [[RESULT]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI-DENORM: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @fmuladd_neg_2.0_neg_a_b_f32(float addrspace(1)* %out, float addrspace(1)* %in) #0 {
|
2016-12-22 11:55:35 +08:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%gep.0 = getelementptr float, float addrspace(1)* %out, i32 %tid
|
|
|
|
%gep.1 = getelementptr float, float addrspace(1)* %gep.0, i32 1
|
|
|
|
%gep.out = getelementptr float, float addrspace(1)* %out, i32 %tid
|
|
|
|
|
|
|
|
%r1 = load volatile float, float addrspace(1)* %gep.0
|
|
|
|
%r2 = load volatile float, float addrspace(1)* %gep.1
|
|
|
|
|
2020-08-03 23:19:33 +08:00
|
|
|
%r1.fneg = fneg float %r1
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
%r3 = tail call float @llvm.fmuladd.f32(float -2.0, float %r1.fneg, float %r2)
|
|
|
|
store float %r3, float addrspace(1)* %gep.out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}fmuladd_2.0_neg_a_b_f32:
|
2018-05-01 03:08:16 +08:00
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[R1:v[0-9]+]],
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[R2:v[0-9]+]],
|
|
|
|
|
|
|
|
; GCN-FLUSH-MAD: v_mac_f32_e32 [[R2]], -2.0, [[R1]]
|
|
|
|
; GCN-FLUSH-FMAC: v_fmac_f32_e32 [[R2]], -2.0, [[R1]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; SI-FLUSH: buffer_store_dword [[R2]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI-FLUSH: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[R2]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
2017-10-27 17:06:07 +08:00
|
|
|
; GCN-DENORM-FASTFMA: v_fma_f32 [[RESULT:v[0-9]+]], [[R1]], -2.0, [[R2]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
2017-05-04 22:14:44 +08:00
|
|
|
; GCN-DENORM-SLOWFMA: v_add_f32_e32 [[TMP:v[0-9]+]], [[R1]], [[R1]]
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-SLOWFMA: v_sub_f32_e32 [[RESULT:v[0-9]+]], [[R2]], [[TMP]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; SI-DENORM: buffer_store_dword [[RESULT]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI-DENORM: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @fmuladd_2.0_neg_a_b_f32(float addrspace(1)* %out, float addrspace(1)* %in) #0 {
|
2016-12-22 11:55:35 +08:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%gep.0 = getelementptr float, float addrspace(1)* %out, i32 %tid
|
|
|
|
%gep.1 = getelementptr float, float addrspace(1)* %gep.0, i32 1
|
|
|
|
%gep.out = getelementptr float, float addrspace(1)* %out, i32 %tid
|
|
|
|
|
|
|
|
%r1 = load volatile float, float addrspace(1)* %gep.0
|
|
|
|
%r2 = load volatile float, float addrspace(1)* %gep.1
|
|
|
|
|
2020-08-03 23:19:33 +08:00
|
|
|
%r1.fneg = fneg float %r1
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
%r3 = tail call float @llvm.fmuladd.f32(float 2.0, float %r1.fneg, float %r2)
|
|
|
|
store float %r3, float addrspace(1)* %gep.out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}fmuladd_2.0_a_neg_b_f32:
|
2018-05-01 03:08:16 +08:00
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[R1:v[0-9]+]],
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[R2:v[0-9]+]],
|
|
|
|
; GCN-FLUSH-MAD: v_mad_f32 [[RESULT:v[0-9]+]], [[R1]], 2.0, -[[R2]]
|
|
|
|
; GCN-FLUSH-FMAC: v_fma_f32 [[RESULT:v[0-9]+]], [[R1]], 2.0, -[[R2]]
|
|
|
|
|
2016-12-22 11:55:35 +08:00
|
|
|
; SI-FLUSH: buffer_store_dword [[RESULT]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI-FLUSH: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[RESULT]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; GCN-DENORM-FASTFMA: v_fma_f32 [[RESULT:v[0-9]+]], [[R1]], 2.0, -[[R2]]
|
|
|
|
|
|
|
|
; GCN-DENORM-SLOWFMA: v_add_f32_e32 [[TMP:v[0-9]+]], [[R1]], [[R1]]
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-SLOWFMA: v_sub_f32_e32 [[RESULT:v[0-9]+]], [[TMP]], [[R2]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; SI-DENORM: buffer_store_dword [[RESULT]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI-DENORM: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @fmuladd_2.0_a_neg_b_f32(float addrspace(1)* %out, float addrspace(1)* %in) #0 {
|
2016-12-22 11:55:35 +08:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%gep.0 = getelementptr float, float addrspace(1)* %out, i32 %tid
|
|
|
|
%gep.1 = getelementptr float, float addrspace(1)* %gep.0, i32 1
|
|
|
|
%gep.out = getelementptr float, float addrspace(1)* %out, i32 %tid
|
|
|
|
|
|
|
|
%r1 = load volatile float, float addrspace(1)* %gep.0
|
|
|
|
%r2 = load volatile float, float addrspace(1)* %gep.1
|
|
|
|
|
2020-08-03 23:19:33 +08:00
|
|
|
%r2.fneg = fneg float %r2
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
%r3 = tail call float @llvm.fmuladd.f32(float 2.0, float %r1, float %r2.fneg)
|
|
|
|
store float %r3, float addrspace(1)* %gep.out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}mad_sub_f32:
|
2018-05-01 03:08:16 +08:00
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[REGA:v[0-9]+]]
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[REGB:v[0-9]+]]
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[REGC:v[0-9]+]]
|
2016-12-22 11:55:35 +08:00
|
|
|
; GCN-FLUSH: v_mad_f32 [[RESULT:v[0-9]+]], [[REGA]], [[REGB]], -[[REGC]]
|
|
|
|
|
|
|
|
; GCN-DENORM-FASTFMA-CONTRACT: v_fma_f32 [[RESULT:v[0-9]+]], [[REGA]], [[REGB]], -[[REGC]]
|
|
|
|
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_mul_f32_e32 [[TMP:v[0-9]+]], [[REGA]], [[REGB]]
|
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_sub_f32_e32 [[RESULT:v[0-9]+]], [[TMP]], [[REGC]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-STRICT: v_mul_f32_e32 [[TMP:v[0-9]+]], [[REGA]], [[REGB]]
|
|
|
|
; GCN-DENORM-STRICT: v_sub_f32_e32 [[RESULT:v[0-9]+]], [[TMP]], [[REGC]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; SI: buffer_store_dword [[RESULT]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mad_sub_f32(float addrspace(1)* noalias nocapture %out, float addrspace(1)* noalias nocapture readonly %ptr) #0 {
|
2016-12-22 11:55:35 +08:00
|
|
|
%tid = tail call i32 @llvm.amdgcn.workitem.id.x() #0
|
|
|
|
%tid.ext = sext i32 %tid to i64
|
|
|
|
%gep0 = getelementptr float, float addrspace(1)* %ptr, i64 %tid.ext
|
|
|
|
%add1 = add i64 %tid.ext, 1
|
|
|
|
%gep1 = getelementptr float, float addrspace(1)* %ptr, i64 %add1
|
|
|
|
%add2 = add i64 %tid.ext, 2
|
|
|
|
%gep2 = getelementptr float, float addrspace(1)* %ptr, i64 %add2
|
|
|
|
%outgep = getelementptr float, float addrspace(1)* %out, i64 %tid.ext
|
|
|
|
%a = load volatile float, float addrspace(1)* %gep0, align 4
|
|
|
|
%b = load volatile float, float addrspace(1)* %gep1, align 4
|
|
|
|
%c = load volatile float, float addrspace(1)* %gep2, align 4
|
|
|
|
%mul = fmul float %a, %b
|
|
|
|
%sub = fsub float %mul, %c
|
|
|
|
store float %sub, float addrspace(1)* %outgep, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}mad_sub_inv_f32:
|
2018-05-01 03:08:16 +08:00
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[REGA:v[0-9]+]]
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[REGB:v[0-9]+]]
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[REGC:v[0-9]+]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; GCN-FLUSH: v_mad_f32 [[RESULT:v[0-9]+]], -[[REGA]], [[REGB]], [[REGC]]
|
|
|
|
|
|
|
|
; GCN-DENORM-FASTFMA-CONTRACT: v_fma_f32 [[RESULT:v[0-9]+]], -[[REGA]], [[REGB]], [[REGC]]
|
|
|
|
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_mul_f32_e32 [[TMP:v[0-9]+]], [[REGA]], [[REGB]]
|
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_sub_f32_e32 [[RESULT:v[0-9]+]], [[REGC]], [[TMP]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-STRICT: v_mul_f32_e32 [[TMP:v[0-9]+]], [[REGA]], [[REGB]]
|
|
|
|
; GCN-DENORM-STRICT: v_sub_f32_e32 [[RESULT:v[0-9]+]], [[REGC]], [[TMP]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; SI: buffer_store_dword [[RESULT]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mad_sub_inv_f32(float addrspace(1)* noalias nocapture %out, float addrspace(1)* noalias nocapture readonly %ptr) #0 {
|
2016-12-22 11:55:35 +08:00
|
|
|
%tid = tail call i32 @llvm.amdgcn.workitem.id.x() #0
|
|
|
|
%tid.ext = sext i32 %tid to i64
|
|
|
|
%gep0 = getelementptr float, float addrspace(1)* %ptr, i64 %tid.ext
|
|
|
|
%add1 = add i64 %tid.ext, 1
|
|
|
|
%gep1 = getelementptr float, float addrspace(1)* %ptr, i64 %add1
|
|
|
|
%add2 = add i64 %tid.ext, 2
|
|
|
|
%gep2 = getelementptr float, float addrspace(1)* %ptr, i64 %add2
|
|
|
|
%outgep = getelementptr float, float addrspace(1)* %out, i64 %tid.ext
|
|
|
|
%a = load volatile float, float addrspace(1)* %gep0, align 4
|
|
|
|
%b = load volatile float, float addrspace(1)* %gep1, align 4
|
|
|
|
%c = load volatile float, float addrspace(1)* %gep2, align 4
|
|
|
|
%mul = fmul float %a, %b
|
|
|
|
%sub = fsub float %c, %mul
|
|
|
|
store float %sub, float addrspace(1)* %outgep, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}mad_sub_fabs_f32:
|
2018-05-01 03:08:16 +08:00
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[REGA:v[0-9]+]]
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[REGB:v[0-9]+]]
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[REGC:v[0-9]+]]
|
2016-12-22 11:55:35 +08:00
|
|
|
; GCN-FLUSH: v_mad_f32 [[RESULT:v[0-9]+]], [[REGA]], [[REGB]], -|[[REGC]]|
|
|
|
|
|
|
|
|
; GCN-DENORM-FASTFMA-CONTRACT: v_fma_f32 [[RESULT:v[0-9]+]], [[REGA]], [[REGB]], -|[[REGC]]|
|
|
|
|
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_mul_f32_e32 [[TMP:v[0-9]+]], [[REGA]], [[REGB]]
|
2016-12-22 11:55:35 +08:00
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_sub_f32_e64 [[RESULT:v[0-9]+]], [[TMP]], |[[REGC]]|
|
|
|
|
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-STRICT: v_mul_f32_e32 [[TMP:v[0-9]+]], [[REGA]], [[REGB]]
|
2016-12-22 11:55:35 +08:00
|
|
|
; GCN-DENORM-STRICT: v_sub_f32_e64 [[RESULT:v[0-9]+]], [[TMP]], |[[REGC]]|
|
|
|
|
|
|
|
|
; SI: buffer_store_dword [[RESULT]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mad_sub_fabs_f32(float addrspace(1)* noalias nocapture %out, float addrspace(1)* noalias nocapture readonly %ptr) #0 {
|
2016-12-22 11:55:35 +08:00
|
|
|
%tid = tail call i32 @llvm.amdgcn.workitem.id.x() #0
|
|
|
|
%tid.ext = sext i32 %tid to i64
|
|
|
|
%gep0 = getelementptr float, float addrspace(1)* %ptr, i64 %tid.ext
|
|
|
|
%add1 = add i64 %tid.ext, 1
|
|
|
|
%gep1 = getelementptr float, float addrspace(1)* %ptr, i64 %add1
|
|
|
|
%add2 = add i64 %tid.ext, 2
|
|
|
|
%gep2 = getelementptr float, float addrspace(1)* %ptr, i64 %add2
|
|
|
|
%outgep = getelementptr float, float addrspace(1)* %out, i64 %tid.ext
|
|
|
|
%a = load volatile float, float addrspace(1)* %gep0, align 4
|
|
|
|
%b = load volatile float, float addrspace(1)* %gep1, align 4
|
|
|
|
%c = load volatile float, float addrspace(1)* %gep2, align 4
|
|
|
|
%c.abs = call float @llvm.fabs.f32(float %c) #0
|
|
|
|
%mul = fmul float %a, %b
|
|
|
|
%sub = fsub float %mul, %c.abs
|
|
|
|
store float %sub, float addrspace(1)* %outgep, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}mad_sub_fabs_inv_f32:
|
2018-05-01 03:08:16 +08:00
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[REGA:v[0-9]+]]
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[REGB:v[0-9]+]]
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[REGC:v[0-9]+]]
|
|
|
|
; GCN-FLUSH-MAD: v_mad_f32 [[RESULT:v[0-9]+]], -[[REGA]], [[REGB]], |[[REGC]]|
|
|
|
|
; GCN-FLUSH-FMA: v_fma_f32 [[RESULT:v[0-9]+]], -[[REGA]], [[REGB]], |[[REGC]]|
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; GCN-DENORM-FASTFMA-CONTRACT: v_fma_f32 [[RESULT:v[0-9]+]], -[[REGA]], [[REGB]], |[[REGC]]|
|
|
|
|
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_mul_f32_e32 [[TMP:v[0-9]+]], [[REGA]], [[REGB]]
|
2016-12-22 11:55:35 +08:00
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_sub_f32_e64 [[RESULT:v[0-9]+]], |[[REGC]]|, [[TMP]]
|
|
|
|
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-STRICT: v_mul_f32_e32 [[TMP:v[0-9]+]], [[REGA]], [[REGB]]
|
2016-12-22 11:55:35 +08:00
|
|
|
; GCN-DENORM-STRICT: v_sub_f32_e64 [[RESULT:v[0-9]+]], |[[REGC]]|, [[TMP]]
|
|
|
|
|
|
|
|
; SI: buffer_store_dword [[RESULT]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mad_sub_fabs_inv_f32(float addrspace(1)* noalias nocapture %out, float addrspace(1)* noalias nocapture readonly %ptr) #0 {
|
2016-12-22 11:55:35 +08:00
|
|
|
%tid = tail call i32 @llvm.amdgcn.workitem.id.x() #0
|
|
|
|
%tid.ext = sext i32 %tid to i64
|
|
|
|
%gep0 = getelementptr float, float addrspace(1)* %ptr, i64 %tid.ext
|
|
|
|
%add1 = add i64 %tid.ext, 1
|
|
|
|
%gep1 = getelementptr float, float addrspace(1)* %ptr, i64 %add1
|
|
|
|
%add2 = add i64 %tid.ext, 2
|
|
|
|
%gep2 = getelementptr float, float addrspace(1)* %ptr, i64 %add2
|
|
|
|
%outgep = getelementptr float, float addrspace(1)* %out, i64 %tid.ext
|
|
|
|
%a = load volatile float, float addrspace(1)* %gep0, align 4
|
|
|
|
%b = load volatile float, float addrspace(1)* %gep1, align 4
|
|
|
|
%c = load volatile float, float addrspace(1)* %gep2, align 4
|
|
|
|
%c.abs = call float @llvm.fabs.f32(float %c) #0
|
|
|
|
%mul = fmul float %a, %b
|
|
|
|
%sub = fsub float %c.abs, %mul
|
|
|
|
store float %sub, float addrspace(1)* %outgep, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}neg_neg_mad_f32:
|
2018-05-01 03:08:16 +08:00
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[REGA:v[0-9]+]]
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[REGB:v[0-9]+]]
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[REGC:v[0-9]+]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-FLUSH: v_mac_f32_e32 [[REGC]], [[REGA]], [[REGB]]
|
2016-12-22 11:55:35 +08:00
|
|
|
; SI-FLUSH: buffer_store_dword [[REGC]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI-FLUSH: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[REGC]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; GCN-DENORM-FASTFMA-CONTRACT: v_fma_f32 [[RESULT:v[0-9]+]], [[REGA]], [[REGB]], [[REGC]]
|
|
|
|
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_mul_f32_e32 [[TMP:v[0-9]+]], [[REGA]], [[REGB]]
|
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_add_f32_e32 [[RESULT:v[0-9]+]], [[REGC]], [[TMP]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-STRICT: v_mul_f32_e32 [[TMP:v[0-9]+]], [[REGA]], [[REGB]]
|
|
|
|
; GCN-DENORM-STRICT: v_add_f32_e32 [[RESULT:v[0-9]+]], [[REGC]], [[TMP]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; SI-DENORM: buffer_store_dword [[RESULT]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI-DENORM: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @neg_neg_mad_f32(float addrspace(1)* noalias nocapture %out, float addrspace(1)* noalias nocapture readonly %ptr) #0 {
|
2016-12-22 11:55:35 +08:00
|
|
|
%tid = tail call i32 @llvm.amdgcn.workitem.id.x() #0
|
|
|
|
%tid.ext = sext i32 %tid to i64
|
|
|
|
%gep0 = getelementptr float, float addrspace(1)* %ptr, i64 %tid.ext
|
|
|
|
%add1 = add i64 %tid.ext, 1
|
|
|
|
%gep1 = getelementptr float, float addrspace(1)* %ptr, i64 %add1
|
|
|
|
%add2 = add i64 %tid.ext, 2
|
|
|
|
%gep2 = getelementptr float, float addrspace(1)* %ptr, i64 %add2
|
|
|
|
%outgep = getelementptr float, float addrspace(1)* %out, i64 %tid.ext
|
|
|
|
%a = load volatile float, float addrspace(1)* %gep0, align 4
|
|
|
|
%b = load volatile float, float addrspace(1)* %gep1, align 4
|
|
|
|
%c = load volatile float, float addrspace(1)* %gep2, align 4
|
2020-08-03 23:19:33 +08:00
|
|
|
%nega = fneg float %a
|
|
|
|
%negb = fneg float %b
|
2016-12-22 11:55:35 +08:00
|
|
|
%mul = fmul float %nega, %negb
|
|
|
|
%sub = fadd float %mul, %c
|
|
|
|
store float %sub, float addrspace(1)* %outgep, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}mad_fabs_sub_f32:
|
2018-05-01 03:08:16 +08:00
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[REGA:v[0-9]+]]
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[REGB:v[0-9]+]]
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[REGC:v[0-9]+]]
|
2016-12-22 11:55:35 +08:00
|
|
|
; GCN-FLUSH: v_mad_f32 [[RESULT:v[0-9]+]], [[REGA]], |[[REGB]]|, -[[REGC]]
|
|
|
|
|
|
|
|
; GCN-DENORM-FASTFMA-CONTRACT: v_fma_f32 [[RESULT:v[0-9]+]], [[REGA]], |[[REGB]]|, -[[REGC]]
|
|
|
|
|
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_mul_f32_e64 [[TMP:v[0-9]+]], [[REGA]], |[[REGB]]|
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_sub_f32_e32 [[RESULT:v[0-9]+]], [[TMP]], [[REGC]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; GCN-DENORM-STRICT: v_mul_f32_e64 [[TMP:v[0-9]+]], [[REGA]], |[[REGB]]|
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-STRICT: v_sub_f32_e32 [[RESULT:v[0-9]+]], [[TMP]], [[REGC]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; SI: buffer_store_dword [[RESULT]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @mad_fabs_sub_f32(float addrspace(1)* noalias nocapture %out, float addrspace(1)* noalias nocapture readonly %ptr) #0 {
|
2016-12-22 11:55:35 +08:00
|
|
|
%tid = tail call i32 @llvm.amdgcn.workitem.id.x() #0
|
|
|
|
%tid.ext = sext i32 %tid to i64
|
|
|
|
%gep0 = getelementptr float, float addrspace(1)* %ptr, i64 %tid.ext
|
|
|
|
%add1 = add i64 %tid.ext, 1
|
|
|
|
%gep1 = getelementptr float, float addrspace(1)* %ptr, i64 %add1
|
|
|
|
%add2 = add i64 %tid.ext, 2
|
|
|
|
%gep2 = getelementptr float, float addrspace(1)* %ptr, i64 %add2
|
|
|
|
%outgep = getelementptr float, float addrspace(1)* %out, i64 %tid.ext
|
|
|
|
%a = load volatile float, float addrspace(1)* %gep0, align 4
|
|
|
|
%b = load volatile float, float addrspace(1)* %gep1, align 4
|
|
|
|
%c = load volatile float, float addrspace(1)* %gep2, align 4
|
|
|
|
%b.abs = call float @llvm.fabs.f32(float %b) #0
|
|
|
|
%mul = fmul float %a, %b.abs
|
|
|
|
%sub = fsub float %mul, %c
|
|
|
|
store float %sub, float addrspace(1)* %outgep, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}fsub_c_fadd_a_a_f32:
|
2018-05-01 03:08:16 +08:00
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[R1:v[0-9]+]],
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[R2:v[0-9]+]],
|
2016-12-22 11:55:35 +08:00
|
|
|
; GCN-FLUSH: v_mac_f32_e32 [[R2]], -2.0, [[R1]]
|
|
|
|
; SI-FLUSH: buffer_store_dword [[R2]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI-FLUSH: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[R2]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; GCN-DENORM-FASTFMA-CONTRACT: v_fma_f32 [[RESULT:v[0-9]+]], [[R1]], -2.0, [[R2]]
|
|
|
|
|
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_add_f32_e32 [[TMP:v[0-9]+]], [[R1]], [[R1]]
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_sub_f32_e32 [[RESULT:v[0-9]+]], [[R2]], [[TMP]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; GCN-DENORM-STRICT: v_add_f32_e32 [[TMP:v[0-9]+]], [[R1]], [[R1]]
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-STRICT: v_sub_f32_e32 [[RESULT:v[0-9]+]], [[R2]], [[TMP]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; SI-DENORM: buffer_store_dword [[RESULT]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI-DENORM: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @fsub_c_fadd_a_a_f32(float addrspace(1)* %out, float addrspace(1)* %in) #0 {
|
2016-12-22 11:55:35 +08:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
|
|
|
%gep.0 = getelementptr float, float addrspace(1)* %out, i32 %tid
|
|
|
|
%gep.1 = getelementptr float, float addrspace(1)* %gep.0, i32 1
|
|
|
|
%gep.out = getelementptr float, float addrspace(1)* %out, i32 %tid
|
|
|
|
|
|
|
|
%r1 = load volatile float, float addrspace(1)* %gep.0
|
|
|
|
%r2 = load volatile float, float addrspace(1)* %gep.1
|
|
|
|
|
|
|
|
%add = fadd float %r1, %r1
|
|
|
|
%r3 = fsub float %r2, %add
|
|
|
|
|
|
|
|
store float %r3, float addrspace(1)* %gep.out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}fsub_fadd_a_a_c_f32:
|
2018-05-01 03:08:16 +08:00
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[R1:v[0-9]+]],
|
|
|
|
; GCN: {{buffer|flat|global}}_load_dword [[R2:v[0-9]+]],
|
2016-12-22 12:03:40 +08:00
|
|
|
; GCN-FLUSH: v_mad_f32 [[RESULT:v[0-9]+]], [[R1]], 2.0, -[[R2]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; GCN-DENORM-FASTFMA-CONTRACT: v_fma_f32 [[RESULT:v[0-9]+]], [[R1]], 2.0, -[[R2]]
|
|
|
|
|
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_add_f32_e32 [[TMP:v[0-9]+]], [[R1]], [[R1]]
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-SLOWFMA-CONTRACT: v_sub_f32_e32 [[RESULT:v[0-9]+]], [[TMP]], [[R2]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; GCN-DENORM-STRICT: v_add_f32_e32 [[TMP:v[0-9]+]], [[R1]], [[R1]]
|
2017-07-11 03:53:57 +08:00
|
|
|
; GCN-DENORM-STRICT: v_sub_f32_e32 [[RESULT:v[0-9]+]], [[TMP]], [[R2]]
|
2016-12-22 11:55:35 +08:00
|
|
|
|
|
|
|
; SI: buffer_store_dword [[RESULT]]
|
2018-05-01 03:08:16 +08:00
|
|
|
; VI: {{global|flat}}_store_dword v{{\[[0-9]+:[0-9]+\]}}, [[RESULT]]
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @fsub_fadd_a_a_c_f32(float addrspace(1)* %out, float addrspace(1)* %in) #0 {
|
2016-12-22 11:55:35 +08:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
|
|
|
%gep.0 = getelementptr float, float addrspace(1)* %out, i32 %tid
|
|
|
|
%gep.1 = getelementptr float, float addrspace(1)* %gep.0, i32 1
|
|
|
|
%gep.out = getelementptr float, float addrspace(1)* %out, i32 %tid
|
|
|
|
|
|
|
|
%r1 = load volatile float, float addrspace(1)* %gep.0
|
|
|
|
%r2 = load volatile float, float addrspace(1)* %gep.1
|
|
|
|
|
|
|
|
%add = fadd float %r1, %r1
|
|
|
|
%r3 = fsub float %add, %r2
|
|
|
|
|
|
|
|
store float %r3, float addrspace(1)* %gep.out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
attributes #0 = { nounwind }
|
|
|
|
attributes #1 = { nounwind readnone }
|