1; RUN: llc -march=amdgcn < %s | FileCheck -allow-deprecated-dag-overlap -check-prefix=GCN -check-prefix=SI -check-prefix=FUNC  %s
2; RUN: llc -march=amdgcn -mcpu=tonga < %s | FileCheck -allow-deprecated-dag-overlap -check-prefix=GCN -check-prefix=GFX8 --check-prefix=FUNC %s
3; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -allow-deprecated-dag-overlap -check-prefix=EG -check-prefix=FUNC %s
4; RUN: llc -march=r600 -mcpu=cayman < %s | FileCheck -allow-deprecated-dag-overlap -check-prefix=CM -check-prefix=FUNC %s
5
6; FUNC-LABEL: {{^}}test:
7; EG: LOG_IEEE
8; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
9; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
10; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
11; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}}
12; GCN: v_log_f32_e32 v{{[0-9]+}}, v{{[0-9]+}}
13; GCN: v_mul_f32_e32 v{{[0-9]+}}, 0x3f317218, v{{[0-9]+}}
14define void @test(float addrspace(1)* %out, float %in) {
15entry:
16   %res = call float @llvm.log.f32(float %in)
17   store float %res, float addrspace(1)* %out
18   ret void
19}
20
21; FUNC-LABEL: {{^}}testv2:
22; EG: LOG_IEEE
23; EG: LOG_IEEE
24; FIXME: We should be able to merge these packets together on Cayman so we
25; have a maximum of 4 instructions.
26; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
27; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
28; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
29; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
30; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
31; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
32; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}}
33; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}}
34; GCN: v_log_f32_e32 v{{[0-9]+}}, v{{[0-9]+}}
35; SI: v_mov_b32_e32 v[[R_F32_LOG_CONST:[0-9]+]], 0x3f317218
36; GCN: v_log_f32_e32 v{{[0-9]+}}, v{{[0-9]+}}
37; GFX8: v_mov_b32_e32 v[[R_F32_LOG_CONST:[0-9]+]], 0x3f317218
38; GCN: v_mul_f32_e32 v{{[0-9]+}}, v{{[0-9]+}}, v[[R_F32_LOG_CONST]]
39; GCN: v_mul_f32_e32 v{{[0-9]+}}, v{{[0-9]+}}, v[[R_F32_LOG_CONST]]
40define void @testv2(<2 x float> addrspace(1)* %out, <2 x float> %in) {
41entry:
42  %res = call <2 x float> @llvm.log.v2f32(<2 x float> %in)
43  store <2 x float> %res, <2 x float> addrspace(1)* %out
44  ret void
45}
46
47; FUNC-LABEL: {{^}}testv4:
48; EG: LOG_IEEE
49; EG: LOG_IEEE
50; EG: LOG_IEEE
51; EG: LOG_IEEE
52; FIXME: We should be able to merge these packets together on Cayman so we
53; have a maximum of 4 instructions.
54; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
55; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
56; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
57; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
58; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
59; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
60; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
61; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
62; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
63; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
64; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
65; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}} (MASKED)
66; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}}
67; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}}
68; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}}
69; CM-DAG: LOG_IEEE T{{[0-9]+\.[XYZW]}}
70; GCN: v_log_f32_e32 v{{[0-9]+}}, v{{[0-9]+}}
71; SI: v_mov_b32_e32 v[[R_F32_LOG_CONST:[0-9]+]], 0x3f317218
72; GCN: v_log_f32_e32 v{{[0-9]+}}, v{{[0-9]+}}
73; GCN: v_log_f32_e32 v{{[0-9]+}}, v{{[0-9]+}}
74; GCN: v_log_f32_e32 v{{[0-9]+}}, v{{[0-9]+}}
75; GFX8: v_mov_b32_e32 v[[R_F32_LOG_CONST:[0-9]+]], 0x3f317218
76; GCN: v_mul_f32_e32 v{{[0-9]+}}, v{{[0-9]+}}, v[[R_F32_LOG_CONST]]
77; GCN: v_mul_f32_e32 v{{[0-9]+}}, v{{[0-9]+}}, v[[R_F32_LOG_CONST]]
78; GCN: v_mul_f32_e32 v{{[0-9]+}}, v{{[0-9]+}}, v[[R_F32_LOG_CONST]]
79; GCN: v_mul_f32_e32 v{{[0-9]+}}, v{{[0-9]+}}, v[[R_F32_LOG_CONST]]
80define void @testv4(<4 x float> addrspace(1)* %out, <4 x float> %in) {
81entry:
82  %res = call <4 x float> @llvm.log.v4f32(<4 x float> %in)
83  store <4 x float> %res, <4 x float> addrspace(1)* %out
84  ret void
85}
86
87declare float @llvm.log.f32(float) readnone
88declare <2 x float> @llvm.log.v2f32(<2 x float>) readnone
89declare <4 x float> @llvm.log.v4f32(<4 x float>) readnone
90