2021-01-06 06:37:29 +08:00
|
|
|
; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -enable-var-scope --check-prefixes=GCN,SI %s
|
|
|
|
; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -enable-var-scope --check-prefixes=GCN,GFX89 %s
|
|
|
|
; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=gfx900 -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -enable-var-scope --check-prefixes=GCN,GFX89 %s
|
2017-01-14 03:49:25 +08:00
|
|
|
|
|
|
|
declare half @llvm.copysign.f16(half, half)
|
|
|
|
declare float @llvm.copysign.f32(float, float)
|
|
|
|
declare double @llvm.copysign.f64(double, double)
|
|
|
|
declare <2 x half> @llvm.copysign.v2f16(<2 x half>, <2 x half>)
|
|
|
|
declare <3 x half> @llvm.copysign.v3f16(<3 x half>, <3 x half>)
|
|
|
|
declare <4 x half> @llvm.copysign.v4f16(<4 x half>, <4 x half>)
|
|
|
|
|
2017-07-05 01:32:00 +08:00
|
|
|
declare i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
|
2017-02-28 06:15:25 +08:00
|
|
|
; GCN-LABEL: {{^}}test_copysign_f16:
|
2017-07-05 01:32:00 +08:00
|
|
|
; SI: {{buffer|flat}}_load_ushort v[[MAG:[0-9]+]]
|
2017-09-20 04:54:38 +08:00
|
|
|
; SI: {{buffer|flat}}_load_ushort v[[SIGN:[0-9]+]]
|
2017-01-14 03:49:25 +08:00
|
|
|
; SI: s_brev_b32 s[[CONST:[0-9]+]], -2
|
2017-03-11 08:29:27 +08:00
|
|
|
; SI-DAG: v_cvt_f32_f16_e32 v[[MAG_F32:[0-9]+]], v[[MAG]]
|
|
|
|
; SI-DAG: v_cvt_f32_f16_e32 v[[SIGN_F32:[0-9]+]], v[[SIGN]]
|
2017-01-14 03:49:25 +08:00
|
|
|
; SI: v_bfi_b32 v[[OUT_F32:[0-9]+]], s[[CONST]], v[[MAG_F32]], v[[SIGN_F32]]
|
|
|
|
; SI: v_cvt_f16_f32_e32 v[[OUT:[0-9]+]], v[[OUT_F32]]
|
2017-07-05 01:32:00 +08:00
|
|
|
; GFX89: {{buffer|flat}}_load_ushort v[[MAG:[0-9]+]]
|
2017-09-20 04:54:38 +08:00
|
|
|
; GFX89: {{buffer|flat}}_load_ushort v[[SIGN:[0-9]+]]
|
2017-04-07 04:58:30 +08:00
|
|
|
; GFX89: s_movk_i32 s[[CONST:[0-9]+]], 0x7fff
|
|
|
|
; GFX89: v_bfi_b32 v[[OUT:[0-9]+]], s[[CONST]], v[[MAG]], v[[SIGN]]
|
2017-01-14 03:49:25 +08:00
|
|
|
; GCN: buffer_store_short v[[OUT]]
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_copysign_f16(
|
2017-01-14 03:49:25 +08:00
|
|
|
half addrspace(1)* %arg_out,
|
|
|
|
half addrspace(1)* %arg_mag,
|
|
|
|
half addrspace(1)* %arg_sign) {
|
|
|
|
entry:
|
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
|
|
|
%mag = load volatile half, half addrspace(1)* %arg_mag
|
|
|
|
%sign = load volatile half, half addrspace(1)* %arg_sign
|
2017-01-14 03:49:25 +08:00
|
|
|
%out = call half @llvm.copysign.f16(half %mag, half %sign)
|
|
|
|
store half %out, half addrspace(1)* %arg_out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-28 06:15:25 +08:00
|
|
|
; GCN-LABEL: {{^}}test_copysign_out_f32_mag_f16_sign_f32:
|
2017-07-29 09:03:53 +08:00
|
|
|
; GCN-DAG: {{buffer|flat|global}}_load_ushort v[[MAG:[0-9]+]]
|
|
|
|
; GCN-DAG: {{buffer|flat|global}}_load_dword v[[SIGN:[0-9]+]]
|
2017-01-14 03:49:25 +08:00
|
|
|
; GCN-DAG: s_brev_b32 s[[CONST:[0-9]+]], -2
|
|
|
|
; GCN-DAG: v_cvt_f32_f16_e32 v[[MAG_EXT:[0-9]+]], v[[MAG]]
|
|
|
|
; GCN: v_bfi_b32 v[[OUT:[0-9]+]], s[[CONST]], v[[MAG_EXT]], v[[SIGN]]
|
|
|
|
; GCN: buffer_store_dword v[[OUT]]
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_copysign_out_f32_mag_f16_sign_f32(
|
2017-01-14 03:49:25 +08:00
|
|
|
float addrspace(1)* %arg_out,
|
|
|
|
half addrspace(1)* %arg_mag,
|
|
|
|
float addrspace(1)* %arg_sign) {
|
|
|
|
entry:
|
2017-07-05 01:32:00 +08:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%arg_mag_gep = getelementptr half, half addrspace(1)* %arg_mag, i32 %tid
|
|
|
|
%mag = load half, half addrspace(1)* %arg_mag_gep
|
2017-01-14 03:49:25 +08:00
|
|
|
%mag.ext = fpext half %mag to float
|
2017-07-05 01:32:00 +08:00
|
|
|
%arg_sign_gep = getelementptr float, float addrspace(1)* %arg_sign, i32 %tid
|
|
|
|
%sign = load float, float addrspace(1)* %arg_sign_gep
|
2017-01-14 03:49:25 +08:00
|
|
|
%out = call float @llvm.copysign.f32(float %mag.ext, float %sign)
|
|
|
|
store float %out, float addrspace(1)* %arg_out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-28 06:15:25 +08:00
|
|
|
; GCN-LABEL: {{^}}test_copysign_out_f64_mag_f16_sign_f64:
|
2017-07-29 09:03:53 +08:00
|
|
|
; GCN-DAG: {{buffer|flat|global}}_load_ushort v[[MAG:[0-9]+]]
|
|
|
|
; GCN-DAG: {{buffer|flat|global}}_load_dwordx2 v{{\[}}[[SIGN_LO:[0-9]+]]:[[SIGN_HI:[0-9]+]]{{\]}}
|
2017-01-14 03:49:25 +08:00
|
|
|
; GCN-DAG: s_brev_b32 s[[CONST:[0-9]+]], -2
|
|
|
|
; GCN-DAG: v_cvt_f32_f16_e32 v[[MAG_EXT:[0-9]+]], v[[MAG]]
|
|
|
|
; GCN-DAG: v_cvt_f64_f32_e32 v{{\[}}[[MAG_EXT_LO:[0-9]+]]:[[MAG_EXT_HI:[0-9]+]]{{\]}}, v[[MAG_EXT]]
|
|
|
|
; GCN: v_bfi_b32 v[[OUT_HI:[0-9]+]], s[[CONST]], v[[MAG_EXT_HI]], v[[SIGN_HI]]
|
|
|
|
; GCN: buffer_store_dwordx2 v{{\[}}[[MAG_EXT_LO]]:[[OUT_HI]]{{\]}}
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_copysign_out_f64_mag_f16_sign_f64(
|
2017-01-14 03:49:25 +08:00
|
|
|
double addrspace(1)* %arg_out,
|
|
|
|
half addrspace(1)* %arg_mag,
|
|
|
|
double addrspace(1)* %arg_sign) {
|
|
|
|
entry:
|
2017-07-05 01:32:00 +08:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%arg_mag_gep = getelementptr half, half addrspace(1)* %arg_mag, i32 %tid
|
|
|
|
%mag = load half, half addrspace(1)* %arg_mag_gep
|
2017-01-14 03:49:25 +08:00
|
|
|
%mag.ext = fpext half %mag to double
|
2017-07-05 01:32:00 +08:00
|
|
|
%arg_sign_gep = getelementptr double, double addrspace(1)* %arg_sign, i32 %tid
|
|
|
|
%sign = load double, double addrspace(1)* %arg_sign_gep
|
2017-01-14 03:49:25 +08:00
|
|
|
%out = call double @llvm.copysign.f64(double %mag.ext, double %sign)
|
|
|
|
store double %out, double addrspace(1)* %arg_out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-28 06:15:25 +08:00
|
|
|
; GCN-LABEL: {{^}}test_copysign_out_f32_mag_f32_sign_f16:
|
2017-07-29 09:03:53 +08:00
|
|
|
; GCN-DAG: {{buffer|flat|global}}_load_dword v[[MAG:[0-9]+]]
|
|
|
|
; GCN-DAG: {{buffer|flat|global}}_load_ushort v[[SIGN:[0-9]+]]
|
2017-01-14 03:49:25 +08:00
|
|
|
; GCN-DAG: s_brev_b32 s[[CONST:[0-9]+]], -2
|
|
|
|
; SI-DAG: v_cvt_f32_f16_e32 v[[SIGN_F32:[0-9]+]], v[[SIGN]]
|
|
|
|
; SI: v_bfi_b32 v[[OUT:[0-9]+]], s[[CONST]], v[[MAG]], v[[SIGN_F32]]
|
2017-04-07 04:58:30 +08:00
|
|
|
; GFX89-DAG: v_lshlrev_b32_e32 v[[SIGN_SHIFT:[0-9]+]], 16, v[[SIGN]]
|
|
|
|
; GFX89: v_bfi_b32 v[[OUT:[0-9]+]], s[[CONST]], v[[MAG]], v[[SIGN_SHIFT]]
|
2017-01-14 03:49:25 +08:00
|
|
|
; GCN: buffer_store_dword v[[OUT]]
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_copysign_out_f32_mag_f32_sign_f16(
|
2017-01-14 03:49:25 +08:00
|
|
|
float addrspace(1)* %arg_out,
|
|
|
|
float addrspace(1)* %arg_mag,
|
|
|
|
half addrspace(1)* %arg_sign) {
|
|
|
|
entry:
|
2017-07-05 01:32:00 +08:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%arg_mag_gep = getelementptr float, float addrspace(1)* %arg_mag, i32 %tid
|
|
|
|
%mag = load float, float addrspace(1)* %arg_mag_gep
|
|
|
|
%arg_sign_gep = getelementptr half, half addrspace(1)* %arg_sign, i32 %tid
|
|
|
|
%sign = load half, half addrspace(1)* %arg_sign_gep
|
2017-01-14 03:49:25 +08:00
|
|
|
%sign.ext = fpext half %sign to float
|
|
|
|
%out = call float @llvm.copysign.f32(float %mag, float %sign.ext)
|
|
|
|
store float %out, float addrspace(1)* %arg_out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-28 06:15:25 +08:00
|
|
|
; GCN-LABEL: {{^}}test_copysign_out_f64_mag_f64_sign_f16:
|
2017-07-29 09:03:53 +08:00
|
|
|
; GCN-DAG: {{buffer|flat|global}}_load_dwordx2 v{{\[}}[[MAG_LO:[0-9]+]]:[[MAG_HI:[0-9]+]]{{\]}}
|
|
|
|
; GCN-DAG: {{buffer|flat|global}}_load_ushort v[[SIGN:[0-9]+]]
|
2017-01-14 03:49:25 +08:00
|
|
|
; GCN-DAG: s_brev_b32 s[[CONST:[0-9]+]], -2
|
|
|
|
; SI-DAG: v_cvt_f32_f16_e32 v[[SIGN_F32:[0-9]+]], v[[SIGN]]
|
|
|
|
; SI: v_bfi_b32 v[[OUT_HI:[0-9]+]], s[[CONST]], v[[MAG_HI]], v[[SIGN_F32]]
|
2017-04-07 04:58:30 +08:00
|
|
|
; GFX89-DAG: v_lshlrev_b32_e32 v[[SIGN_SHIFT:[0-9]+]], 16, v[[SIGN]]
|
|
|
|
; GFX89: v_bfi_b32 v[[OUT_HI:[0-9]+]], s[[CONST]], v[[MAG_HI]], v[[SIGN_SHIFT]]
|
2017-01-14 03:49:25 +08:00
|
|
|
; GCN: buffer_store_dwordx2 v{{\[}}[[MAG_LO]]:[[OUT_HI]]{{\]}}
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_copysign_out_f64_mag_f64_sign_f16(
|
2017-01-14 03:49:25 +08:00
|
|
|
double addrspace(1)* %arg_out,
|
|
|
|
double addrspace(1)* %arg_mag,
|
|
|
|
half addrspace(1)* %arg_sign) {
|
|
|
|
entry:
|
2017-07-05 01:32:00 +08:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%arg_mag_gep = getelementptr double, double addrspace(1)* %arg_mag, i32 %tid
|
|
|
|
%mag = load double, double addrspace(1)* %arg_mag_gep
|
|
|
|
%arg_sign_gep = getelementptr half, half addrspace(1)* %arg_sign, i32 %tid
|
|
|
|
%sign = load half, half addrspace(1)* %arg_sign_gep
|
2017-01-14 03:49:25 +08:00
|
|
|
%sign.ext = fpext half %sign to double
|
|
|
|
%out = call double @llvm.copysign.f64(double %mag, double %sign.ext)
|
|
|
|
store double %out, double addrspace(1)* %arg_out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-28 06:15:25 +08:00
|
|
|
; GCN-LABEL: {{^}}test_copysign_out_f16_mag_f16_sign_f32:
|
2017-07-29 09:03:53 +08:00
|
|
|
; GCN-DAG: {{buffer|flat|global}}_load_ushort v[[MAG:[0-9]+]]
|
|
|
|
; GCN-DAG: {{buffer|flat|global}}_load_dword v[[SIGN:[0-9]+]]
|
2017-01-14 03:49:25 +08:00
|
|
|
; SI-DAG: s_brev_b32 s[[CONST:[0-9]+]], -2
|
|
|
|
; SI-DAG: v_cvt_f32_f16_e32 v[[MAG_F32:[0-9]+]], v[[MAG]]
|
|
|
|
; SI: v_bfi_b32 v[[OUT_F32:[0-9]+]], s[[CONST]], v[[MAG_F32]], v[[SIGN]]
|
|
|
|
; SI: v_cvt_f16_f32_e32 v[[OUT:[0-9]+]], v[[OUT_F32]]
|
2017-04-07 04:58:30 +08:00
|
|
|
; GFX89-DAG: s_movk_i32 s[[CONST:[0-9]+]], 0x7fff
|
|
|
|
; GFX89-DAG: v_lshrrev_b32_e32 v[[SIGN_SHIFT:[0-9]+]], 16, v[[SIGN]]
|
|
|
|
; GFX89: v_bfi_b32 v[[OUT:[0-9]+]], s[[CONST]], v[[MAG]], v[[SIGN_SHIFT]]
|
2017-01-14 03:49:25 +08:00
|
|
|
; GCN: buffer_store_short v[[OUT]]
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_copysign_out_f16_mag_f16_sign_f32(
|
2017-01-14 03:49:25 +08:00
|
|
|
half addrspace(1)* %arg_out,
|
|
|
|
half addrspace(1)* %arg_mag,
|
|
|
|
float addrspace(1)* %arg_sign) {
|
|
|
|
entry:
|
2017-07-05 01:32:00 +08:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%arg_mag_gep = getelementptr half, half addrspace(1)* %arg_mag, i32 %tid
|
|
|
|
%mag = load half, half addrspace(1)* %arg_mag_gep
|
|
|
|
%arg_sign_gep = getelementptr float, float addrspace(1)* %arg_sign, i32 %tid
|
|
|
|
%sign = load float, float addrspace(1)* %arg_sign_gep
|
2017-01-14 03:49:25 +08:00
|
|
|
%sign.trunc = fptrunc float %sign to half
|
|
|
|
%out = call half @llvm.copysign.f16(half %mag, half %sign.trunc)
|
|
|
|
store half %out, half addrspace(1)* %arg_out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-28 06:15:25 +08:00
|
|
|
; GCN-LABEL: {{^}}test_copysign_out_f16_mag_f16_sign_f64:
|
2017-07-29 09:03:53 +08:00
|
|
|
; GCN-DAG: {{buffer|flat|global}}_load_ushort v[[MAG:[0-9]+]]
|
|
|
|
; GCN-DAG: {{buffer|flat|global}}_load_dwordx2 v{{\[}}[[SIGN_LO:[0-9]+]]:[[SIGN_HI:[0-9]+]]{{\]}}
|
2017-01-14 03:49:25 +08:00
|
|
|
; SI-DAG: s_brev_b32 s[[CONST:[0-9]+]], -2
|
|
|
|
; SI-DAG: v_cvt_f32_f16_e32 v[[MAG_F32:[0-9]+]], v[[MAG]]
|
|
|
|
; SI: v_bfi_b32 v[[OUT_F32:[0-9]+]], s[[CONST]], v[[MAG_F32]], v[[SIGN_HI]]
|
|
|
|
; SI: v_cvt_f16_f32_e32 v[[OUT:[0-9]+]], v[[OUT_F32]]
|
2017-04-07 04:58:30 +08:00
|
|
|
; GFX89-DAG: s_movk_i32 s[[CONST:[0-9]+]], 0x7fff
|
|
|
|
; GFX89-DAG: v_lshrrev_b32_e32 v[[SIGN_SHIFT:[0-9]+]], 16, v[[SIGN_HI]]
|
|
|
|
; GFX89: v_bfi_b32 v[[OUT:[0-9]+]], s[[CONST]], v[[MAG]], v[[SIGN_SHIFT]]
|
2017-01-14 03:49:25 +08:00
|
|
|
; GCN: buffer_store_short v[[OUT]]
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_copysign_out_f16_mag_f16_sign_f64(
|
2017-01-14 03:49:25 +08:00
|
|
|
half addrspace(1)* %arg_out,
|
|
|
|
half addrspace(1)* %arg_mag,
|
|
|
|
double addrspace(1)* %arg_sign) {
|
|
|
|
entry:
|
2017-07-05 01:32:00 +08:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%arg_mag_gep = getelementptr half, half addrspace(1)* %arg_mag, i32 %tid
|
2017-01-14 03:49:25 +08:00
|
|
|
%mag = load half, half addrspace(1)* %arg_mag
|
2017-07-05 01:32:00 +08:00
|
|
|
%arg_sign_gep = getelementptr double, double addrspace(1)* %arg_sign, i32 %tid
|
|
|
|
%sign = load double, double addrspace(1)* %arg_sign_gep
|
2017-01-14 03:49:25 +08:00
|
|
|
%sign.trunc = fptrunc double %sign to half
|
|
|
|
%out = call half @llvm.copysign.f16(half %mag, half %sign.trunc)
|
|
|
|
store half %out, half addrspace(1)* %arg_out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-28 06:15:25 +08:00
|
|
|
; GCN-LABEL: {{^}}test_copysign_out_f16_mag_f32_sign_f16:
|
2017-07-29 09:03:53 +08:00
|
|
|
; GCN-DAG: {{buffer|flat|global}}_load_dword v[[MAG:[0-9]+]]
|
|
|
|
; GCN-DAG: {{buffer|flat|global}}_load_ushort v[[SIGN:[0-9]+]]
|
2017-01-14 03:49:25 +08:00
|
|
|
; SI-DAG: s_brev_b32 s[[CONST:[0-9]+]], -2
|
|
|
|
; SI-DAG: v_cvt_f16_f32_e32 v[[MAG_TRUNC:[0-9]+]], v[[MAG]]
|
|
|
|
; SI-DAG: v_cvt_f32_f16_e32 v[[SIGN_F32:[0-9]+]], v[[SIGN]]
|
|
|
|
; SI-DAG: v_cvt_f32_f16_e32 v[[MAG_F32:[0-9]+]], v[[MAG_TRUNC]]
|
|
|
|
; SI: v_bfi_b32 v[[OUT_F32:[0-9]+]], s[[CONST]], v[[MAG_F32]], v[[SIGN_F32]]
|
|
|
|
; SI: v_cvt_f16_f32_e32 v[[OUT:[0-9]+]], v[[OUT_F32]]
|
2017-04-07 04:58:30 +08:00
|
|
|
; GFX89-DAG: s_movk_i32 s[[CONST:[0-9]+]], 0x7fff
|
|
|
|
; GFX89-DAG: v_cvt_f16_f32_e32 v[[MAG_TRUNC:[0-9]+]], v[[MAG]]
|
|
|
|
; GFX89: v_bfi_b32 v[[OUT:[0-9]+]], s[[CONST]], v[[MAG_TRUNC]], v[[SIGN]]
|
2017-01-14 03:49:25 +08:00
|
|
|
; GCN: buffer_store_short v[[OUT]]
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_copysign_out_f16_mag_f32_sign_f16(
|
2017-01-14 03:49:25 +08:00
|
|
|
half addrspace(1)* %arg_out,
|
|
|
|
float addrspace(1)* %arg_mag,
|
|
|
|
half addrspace(1)* %arg_sign) {
|
|
|
|
entry:
|
2017-07-05 01:32:00 +08:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%arg_mag_gep = getelementptr float, float addrspace(1)* %arg_mag, i32 %tid
|
|
|
|
%mag = load float, float addrspace(1)* %arg_mag_gep
|
2017-01-14 03:49:25 +08:00
|
|
|
%mag.trunc = fptrunc float %mag to half
|
2017-07-05 01:32:00 +08:00
|
|
|
%arg_sign_gep = getelementptr half, half addrspace(1)* %arg_sign, i32 %tid
|
|
|
|
%sign = load half, half addrspace(1)* %arg_sign_gep
|
2017-01-14 03:49:25 +08:00
|
|
|
%out = call half @llvm.copysign.f16(half %mag.trunc, half %sign)
|
|
|
|
store half %out, half addrspace(1)* %arg_out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-28 06:15:25 +08:00
|
|
|
; GCN-LABEL: {{^}}test_copysign_out_f16_mag_f64_sign_f16:
|
2017-01-14 03:49:25 +08:00
|
|
|
; GCN: v_bfi_b32
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_copysign_out_f16_mag_f64_sign_f16(
|
2017-01-14 03:49:25 +08:00
|
|
|
half addrspace(1)* %arg_out,
|
|
|
|
double addrspace(1)* %arg_mag,
|
|
|
|
half addrspace(1)* %arg_sign) {
|
|
|
|
entry:
|
|
|
|
%mag = load double, double addrspace(1)* %arg_mag
|
|
|
|
%mag.trunc = fptrunc double %mag to half
|
|
|
|
%sign = load half, half addrspace(1)* %arg_sign
|
|
|
|
%out = call half @llvm.copysign.f16(half %mag.trunc, half %sign)
|
|
|
|
store half %out, half addrspace(1)* %arg_out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-28 06:15:25 +08:00
|
|
|
; GCN-LABEL: {{^}}test_copysign_v2f16:
|
2017-01-14 03:49:25 +08:00
|
|
|
; GCN: v_bfi_b32
|
|
|
|
; GCN: v_bfi_b32
|
2017-04-07 04:58:30 +08:00
|
|
|
; VI: v_or_b32_sdwa v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_0
|
2017-01-14 03:49:25 +08:00
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_copysign_v2f16(
|
2017-01-14 03:49:25 +08:00
|
|
|
<2 x half> addrspace(1)* %arg_out,
|
|
|
|
<2 x half> %arg_mag,
|
|
|
|
<2 x half> %arg_sign) {
|
|
|
|
entry:
|
|
|
|
%out = call <2 x half> @llvm.copysign.v2f16(<2 x half> %arg_mag, <2 x half> %arg_sign)
|
|
|
|
store <2 x half> %out, <2 x half> addrspace(1)* %arg_out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-28 06:15:25 +08:00
|
|
|
; GCN-LABEL: {{^}}test_copysign_v3f16:
|
2017-01-14 03:49:25 +08:00
|
|
|
; GCN: v_bfi_b32
|
|
|
|
; GCN: v_bfi_b32
|
|
|
|
; GCN: v_bfi_b32
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_copysign_v3f16(
|
2017-01-14 03:49:25 +08:00
|
|
|
<3 x half> addrspace(1)* %arg_out,
|
|
|
|
<3 x half> %arg_mag,
|
|
|
|
<3 x half> %arg_sign) {
|
|
|
|
entry:
|
|
|
|
%out = call <3 x half> @llvm.copysign.v3f16(<3 x half> %arg_mag, <3 x half> %arg_sign)
|
|
|
|
store <3 x half> %out, <3 x half> addrspace(1)* %arg_out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-02-28 06:15:25 +08:00
|
|
|
; GCN-LABEL: {{^}}test_copysign_v4f16:
|
2017-01-14 03:49:25 +08:00
|
|
|
; GCN: v_bfi_b32
|
|
|
|
; GCN: v_bfi_b32
|
|
|
|
; GCN: v_bfi_b32
|
|
|
|
; GCN: v_bfi_b32
|
|
|
|
; GCN: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_copysign_v4f16(
|
2017-01-14 03:49:25 +08:00
|
|
|
<4 x half> addrspace(1)* %arg_out,
|
|
|
|
<4 x half> %arg_mag,
|
|
|
|
<4 x half> %arg_sign) {
|
|
|
|
entry:
|
|
|
|
%out = call <4 x half> @llvm.copysign.v4f16(<4 x half> %arg_mag, <4 x half> %arg_sign)
|
|
|
|
store <4 x half> %out, <4 x half> addrspace(1)* %arg_out
|
|
|
|
ret void
|
|
|
|
}
|