R600 -> AMDGPU rename
[oota-llvm.git] / test / CodeGen / AMDGPU / llvm.AMDGPU.rcp.ll
1 ; RUN: llc -march=amdgcn -mcpu=SI -mattr=-fp32-denormals -enable-unsafe-fp-math -verify-machineinstrs < %s | FileCheck -check-prefix=SI-UNSAFE -check-prefix=SI -check-prefix=FUNC %s
2 ; RUN: llc -march=amdgcn -mcpu=SI -mattr=-fp32-denormals -verify-machineinstrs < %s | FileCheck -check-prefix=SI-SAFE -check-prefix=SI -check-prefix=FUNC %s
3 ; XUN: llc -march=amdgcn -mcpu=SI -mattr=+fp32-denormals -verify-machineinstrs < %s | FileCheck -check-prefix=SI-SAFE-SPDENORM -check-prefix=SI -check-prefix=FUNC %s
4 ; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-fp32-denormals -enable-unsafe-fp-math -verify-machineinstrs < %s | FileCheck -check-prefix=SI-UNSAFE -check-prefix=SI -check-prefix=FUNC %s
5 ; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-fp32-denormals -verify-machineinstrs < %s | FileCheck -check-prefix=SI-SAFE -check-prefix=SI -check-prefix=FUNC %s
6 ; XUN: llc -march=amdgcn -mcpu=tonga -mattr=+fp32-denormals -verify-machineinstrs < %s | FileCheck -check-prefix=SI-SAFE-SPDENORM -check-prefix=SI -check-prefix=FUNC %s
7
8 ; RUN: llc -march=r600 -mcpu=cypress -verify-machineinstrs < %s | FileCheck -check-prefix=EG-SAFE -check-prefix=FUNC %s
9 ; RUN: llc -march=r600 -mcpu=cayman -verify-machineinstrs < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
10
11 declare float @llvm.AMDGPU.rcp.f32(float) nounwind readnone
12 declare double @llvm.AMDGPU.rcp.f64(double) nounwind readnone
13
14 declare float @llvm.sqrt.f32(float) nounwind readnone
15
16 ; FUNC-LABEL: {{^}}rcp_f32:
17 ; SI: v_rcp_f32_e32
18 ; EG: RECIP_IEEE
19 define void @rcp_f32(float addrspace(1)* %out, float %src) nounwind {
20   %rcp = call float @llvm.AMDGPU.rcp.f32(float %src) nounwind readnone
21   store float %rcp, float addrspace(1)* %out, align 4
22   ret void
23 }
24
25 ; FIXME: Evergreen only ever does unsafe fp math.
26 ; FUNC-LABEL: {{^}}rcp_pat_f32:
27
28 ; SI-SAFE: v_rcp_f32_e32
29 ; XSI-SAFE-SPDENORM-NOT: v_rcp_f32_e32
30
31 ; EG: RECIP_IEEE
32
33 define void @rcp_pat_f32(float addrspace(1)* %out, float %src) nounwind {
34   %rcp = fdiv float 1.0, %src
35   store float %rcp, float addrspace(1)* %out, align 4
36   ret void
37 }
38
39 ; FUNC-LABEL: {{^}}rsq_rcp_pat_f32:
40 ; SI-UNSAFE: v_rsq_f32_e32
41 ; SI-SAFE: v_sqrt_f32_e32
42 ; SI-SAFE: v_rcp_f32_e32
43
44 ; EG: RECIPSQRT_IEEE
45 define void @rsq_rcp_pat_f32(float addrspace(1)* %out, float %src) nounwind {
46   %sqrt = call float @llvm.sqrt.f32(float %src) nounwind readnone
47   %rcp = call float @llvm.AMDGPU.rcp.f32(float %sqrt) nounwind readnone
48   store float %rcp, float addrspace(1)* %out, align 4
49   ret void
50 }