blob: 27a88f7b59e7da49ff04e323da8b3de272856f76 [file] [log] [blame]
Matt Arsenaulte3862cd2016-07-26 23:25:44 +00001; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
2; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -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
Matt Arsenaultbef34e22016-01-22 21:30:34 +00004; RUN: llc -march=r600 -mcpu=cayman -verify-machineinstrs < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
5
Matt Arsenaultbef34e22016-01-22 21:30:34 +00006; FUNC-LABEL: {{^}}rcp_pat_f32:
Matt Arsenaulte3862cd2016-07-26 23:25:44 +00007; GCN: s_load_dword [[SRC:s[0-9]+]]
8; GCN: v_rcp_f32_e32 [[RCP:v[0-9]+]], [[SRC]]
9; GCN: buffer_store_dword [[RCP]]
10
Matt Arsenaultbef34e22016-01-22 21:30:34 +000011; EG: RECIP_IEEE
Matt Arsenaulte3862cd2016-07-26 23:25:44 +000012define void @rcp_pat_f32(float addrspace(1)* %out, float %src) #0 {
Matt Arsenaultbef34e22016-01-22 21:30:34 +000013 %rcp = fdiv float 1.0, %src
14 store float %rcp, float addrspace(1)* %out, align 4
15 ret void
16}
Matt Arsenaulte3862cd2016-07-26 23:25:44 +000017
18; FUNC-LABEL: {{^}}rcp_ulp25_pat_f32:
19; GCN: s_load_dword [[SRC:s[0-9]+]]
20; GCN: v_rcp_f32_e32 [[RCP:v[0-9]+]], [[SRC]]
21; GCN: buffer_store_dword [[RCP]]
22
23; EG: RECIP_IEEE
24define void @rcp_ulp25_pat_f32(float addrspace(1)* %out, float %src) #0 {
25 %rcp = fdiv float 1.0, %src, !fpmath !0
26 store float %rcp, float addrspace(1)* %out, align 4
27 ret void
28}
29
30; FUNC-LABEL: {{^}}rcp_fast_ulp25_pat_f32:
31; GCN: s_load_dword [[SRC:s[0-9]+]]
32; GCN: v_rcp_f32_e32 [[RCP:v[0-9]+]], [[SRC]]
33; GCN: buffer_store_dword [[RCP]]
34
35; EG: RECIP_IEEE
36define void @rcp_fast_ulp25_pat_f32(float addrspace(1)* %out, float %src) #0 {
37 %rcp = fdiv fast float 1.0, %src, !fpmath !0
38 store float %rcp, float addrspace(1)* %out, align 4
39 ret void
40}
41
42; FUNC-LABEL: {{^}}rcp_arcp_ulp25_pat_f32:
43; GCN: s_load_dword [[SRC:s[0-9]+]]
44; GCN: v_rcp_f32_e32 [[RCP:v[0-9]+]], [[SRC]]
45; GCN: buffer_store_dword [[RCP]]
46
47; EG: RECIP_IEEE
48define void @rcp_arcp_ulp25_pat_f32(float addrspace(1)* %out, float %src) #0 {
49 %rcp = fdiv arcp float 1.0, %src, !fpmath !0
50 store float %rcp, float addrspace(1)* %out, align 4
51 ret void
52}
53
54; FUNC-LABEL: {{^}}rcp_global_fast_ulp25_pat_f32:
55; GCN: s_load_dword [[SRC:s[0-9]+]]
56; GCN: v_rcp_f32_e32 [[RCP:v[0-9]+]], [[SRC]]
57; GCN: buffer_store_dword [[RCP]]
58
59; EG: RECIP_IEEE
60define void @rcp_global_fast_ulp25_pat_f32(float addrspace(1)* %out, float %src) #2 {
61 %rcp = fdiv float 1.0, %src, !fpmath !0
62 store float %rcp, float addrspace(1)* %out, align 4
63 ret void
64}
65
66; FUNC-LABEL: {{^}}rcp_fabs_pat_f32:
67; GCN: s_load_dword [[SRC:s[0-9]+]]
68; GCN: v_rcp_f32_e64 [[RCP:v[0-9]+]], |[[SRC]]|
69; GCN: buffer_store_dword [[RCP]]
70
71; EG: RECIP_IEEE
72define void @rcp_fabs_pat_f32(float addrspace(1)* %out, float %src) #0 {
73 %src.fabs = call float @llvm.fabs.f32(float %src)
74 %rcp = fdiv float 1.0, %src.fabs
75 store float %rcp, float addrspace(1)* %out, align 4
76 ret void
77}
78
79; FIXME: fneg folded into constant 1
80; FUNC-LABEL: {{^}}rcp_fabs_fneg_pat_f32:
81define void @rcp_fabs_fneg_pat_f32(float addrspace(1)* %out, float %src) #0 {
82 %src.fabs = call float @llvm.fabs.f32(float %src)
83 %src.fabs.fneg = fsub float -0.0, %src.fabs
84 %rcp = fdiv float 1.0, %src.fabs.fneg
85 store float %rcp, float addrspace(1)* %out, align 4
86 ret void
87}
88
89
90declare float @llvm.fabs.f32(float) #1
91
92attributes #0 = { nounwind "unsafe-fp-math"="false" }
93attributes #1 = { nounwind readnone }
94attributes #2 = { nounwind "unsafe-fp-math"="true" }
95
96!0 = !{float 2.500000e+00}