1; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=GCN -check-prefix=FUNC %s
2; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=VI -check-prefix=GCN -check-prefix=FUNC %s
3; RUN: llc -march=r600 -mcpu=cypress -verify-machineinstrs < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
4
5declare float @llvm.copysign.f32(float, float) nounwind readnone
6declare <2 x float> @llvm.copysign.v2f32(<2 x float>, <2 x float>) nounwind readnone
7declare <4 x float> @llvm.copysign.v4f32(<4 x float>, <4 x float>) nounwind readnone
8
9; Try to identify arg based on higher address.
10; FUNC-LABEL: {{^}}test_copysign_f32:
11; SI: s_load_dword [[SMAG:s[0-9]+]], {{.*}} 0xb
12; SI: s_load_dword [[SSIGN:s[0-9]+]], {{.*}} 0xc
13; VI: s_load_dword [[SMAG:s[0-9]+]], {{.*}} 0x2c
14; VI: s_load_dword [[SSIGN:s[0-9]+]], {{.*}} 0x30
15; GCN-DAG: v_mov_b32_e32 [[VSIGN:v[0-9]+]], [[SSIGN]]
16; GCN-DAG: v_mov_b32_e32 [[VMAG:v[0-9]+]], [[SMAG]]
17; GCN-DAG: s_brev_b32 [[SCONST:s[0-9]+]], -2
18; GCN: v_bfi_b32 [[RESULT:v[0-9]+]], [[SCONST]], [[VMAG]], [[VSIGN]]
19; GCN: buffer_store_dword [[RESULT]],
20; GCN: s_endpgm
21
22; EG: BFI_INT
23define void @test_copysign_f32(float addrspace(1)* %out, float %mag, float %sign) nounwind {
24  %result = call float @llvm.copysign.f32(float %mag, float %sign)
25  store float %result, float addrspace(1)* %out, align 4
26  ret void
27}
28
29; FUNC-LABEL: {{^}}test_copysign_v2f32:
30; GCN: s_endpgm
31
32; EG: BFI_INT
33; EG: BFI_INT
34define void @test_copysign_v2f32(<2 x float> addrspace(1)* %out, <2 x float> %mag, <2 x float> %sign) nounwind {
35  %result = call <2 x float> @llvm.copysign.v2f32(<2 x float> %mag, <2 x float> %sign)
36  store <2 x float> %result, <2 x float> addrspace(1)* %out, align 8
37  ret void
38}
39
40; FUNC-LABEL: {{^}}test_copysign_v4f32:
41; GCN: s_endpgm
42
43; EG: BFI_INT
44; EG: BFI_INT
45; EG: BFI_INT
46; EG: BFI_INT
47define void @test_copysign_v4f32(<4 x float> addrspace(1)* %out, <4 x float> %mag, <4 x float> %sign) nounwind {
48  %result = call <4 x float> @llvm.copysign.v4f32(<4 x float> %mag, <4 x float> %sign)
49  store <4 x float> %result, <4 x float> addrspace(1)* %out, align 16
50  ret void
51}
52
53