blob: 0d1095cf26832222436cb2e79b31aaaa538cd8b2 [file] [log] [blame]
Matt Arsenaulte93d06a2015-01-13 20:53:18 +00001; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck %s
2; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs -enable-unsafe-fp-math < %s | FileCheck %s
3
4; Run with unsafe-fp-math to make sure nothing tries to turn this into 1 / rsqrt(x)
Tom Stellard8ed7b452013-07-12 18:15:13 +00005
Tom Stellard79243d92014-10-01 17:15:17 +00006; CHECK: {{^}}fsqrt_f32:
Tom Stellard326d6ec2014-11-05 14:50:53 +00007; CHECK: v_sqrt_f32_e32 {{v[0-9]+, v[0-9]+}}
Tom Stellard8ed7b452013-07-12 18:15:13 +00008
9define void @fsqrt_f32(float addrspace(1)* %out, float addrspace(1)* %in) {
10 %r0 = load float addrspace(1)* %in
11 %r1 = call float @llvm.sqrt.f32(float %r0)
12 store float %r1, float addrspace(1)* %out
13 ret void
14}
15
Tom Stellard79243d92014-10-01 17:15:17 +000016; CHECK: {{^}}fsqrt_f64:
Tom Stellard326d6ec2014-11-05 14:50:53 +000017; CHECK: v_sqrt_f64_e32 {{v\[[0-9]+:[0-9]+\], v\[[0-9]+:[0-9]+\]}}
Tom Stellard8ed7b452013-07-12 18:15:13 +000018
19define void @fsqrt_f64(double addrspace(1)* %out, double addrspace(1)* %in) {
20 %r0 = load double addrspace(1)* %in
21 %r1 = call double @llvm.sqrt.f64(double %r0)
22 store double %r1, double addrspace(1)* %out
23 ret void
24}
25
26declare float @llvm.sqrt.f32(float %Val)
27declare double @llvm.sqrt.f64(double %Val)