1; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s 2 3declare float @llvm.amdgcn.rcp.f32(float) #0 4declare double @llvm.amdgcn.rcp.f64(double) #0 5 6declare double @llvm.sqrt.f64(double) #0 7declare float @llvm.sqrt.f32(float) #0 8 9; FUNC-LABEL: {{^}}rcp_undef_f32: 10; SI-NOT: v_rcp_f32 11define amdgpu_kernel void @rcp_undef_f32(float addrspace(1)* %out) #1 { 12 %rcp = call float @llvm.amdgcn.rcp.f32(float undef) 13 store float %rcp, float addrspace(1)* %out, align 4 14 ret void 15} 16 17; FUNC-LABEL: {{^}}rcp_2_f32: 18; SI-NOT: v_rcp_f32 19; SI: v_mov_b32_e32 v{{[0-9]+}}, 0.5 20define amdgpu_kernel void @rcp_2_f32(float addrspace(1)* %out) #1 { 21 %rcp = call float @llvm.amdgcn.rcp.f32(float 2.0) 22 store float %rcp, float addrspace(1)* %out, align 4 23 ret void 24} 25 26; FUNC-LABEL: {{^}}rcp_10_f32: 27; SI-NOT: v_rcp_f32 28; SI: v_mov_b32_e32 v{{[0-9]+}}, 0x3dcccccd 29define amdgpu_kernel void @rcp_10_f32(float addrspace(1)* %out) #1 { 30 %rcp = call float @llvm.amdgcn.rcp.f32(float 10.0) 31 store float %rcp, float addrspace(1)* %out, align 4 32 ret void 33} 34 35; FUNC-LABEL: {{^}}safe_no_fp32_denormals_rcp_f32: 36; SI: v_rcp_f32_e32 [[RESULT:v[0-9]+]], s{{[0-9]+}} 37; SI-NOT: [[RESULT]] 38; SI: buffer_store_dword [[RESULT]] 39define amdgpu_kernel void @safe_no_fp32_denormals_rcp_f32(float addrspace(1)* %out, float %src) #1 { 40 %rcp = fdiv float 1.0, %src, !fpmath !0 41 store float %rcp, float addrspace(1)* %out, align 4 42 ret void 43} 44 45; FUNC-LABEL: {{^}}safe_f32_denormals_rcp_pat_f32: 46; SI: v_rcp_f32_e32 [[RESULT:v[0-9]+]], s{{[0-9]+}} 47; SI-NOT: [[RESULT]] 48; SI: buffer_store_dword [[RESULT]] 49define amdgpu_kernel void @safe_f32_denormals_rcp_pat_f32(float addrspace(1)* %out, float %src) #4 { 50 %rcp = fdiv float 1.0, %src, !fpmath !0 51 store float %rcp, float addrspace(1)* %out, align 4 52 ret void 53} 54 55; FUNC-LABEL: {{^}}unsafe_f32_denormals_rcp_pat_f32: 56; SI: v_div_scale_f32 57define amdgpu_kernel void @unsafe_f32_denormals_rcp_pat_f32(float addrspace(1)* %out, float %src) #3 { 58 %rcp = fdiv float 1.0, %src 59 store float %rcp, float addrspace(1)* %out, align 4 60 ret void 61} 62 63; FUNC-LABEL: {{^}}safe_rsq_rcp_pat_f32: 64; SI: v_rsq_f32_e32 65define amdgpu_kernel void @safe_rsq_rcp_pat_f32(float addrspace(1)* %out, float %src) #1 { 66 %sqrt = call float @llvm.sqrt.f32(float %src) 67 %rcp = call float @llvm.amdgcn.rcp.f32(float %sqrt) 68 store float %rcp, float addrspace(1)* %out, align 4 69 ret void 70} 71 72; FUNC-LABEL: {{^}}unsafe_rsq_rcp_pat_f32: 73; SI: v_rsq_f32_e32 74define amdgpu_kernel void @unsafe_rsq_rcp_pat_f32(float addrspace(1)* %out, float %src) #2 { 75 %sqrt = call float @llvm.sqrt.f32(float %src) 76 %rcp = call float @llvm.amdgcn.rcp.f32(float %sqrt) 77 store float %rcp, float addrspace(1)* %out, align 4 78 ret void 79} 80 81; FUNC-LABEL: {{^}}rcp_f64: 82; SI: v_rcp_f64_e32 [[RESULT:v\[[0-9]+:[0-9]+\]]], s{{\[[0-9]+:[0-9]+\]}} 83; SI-NOT: [[RESULT]] 84; SI: buffer_store_dwordx2 [[RESULT]] 85define amdgpu_kernel void @rcp_f64(double addrspace(1)* %out, double %src) #1 { 86 %rcp = call double @llvm.amdgcn.rcp.f64(double %src) 87 store double %rcp, double addrspace(1)* %out, align 8 88 ret void 89} 90 91; FUNC-LABEL: {{^}}unsafe_rcp_f64: 92; SI: v_rcp_f64_e32 [[RESULT:v\[[0-9]+:[0-9]+\]]], s{{\[[0-9]+:[0-9]+\]}} 93; SI-NOT: [[RESULT]] 94; SI: buffer_store_dwordx2 [[RESULT]] 95define amdgpu_kernel void @unsafe_rcp_f64(double addrspace(1)* %out, double %src) #2 { 96 %rcp = call double @llvm.amdgcn.rcp.f64(double %src) 97 store double %rcp, double addrspace(1)* %out, align 8 98 ret void 99} 100 101; FUNC-LABEL: {{^}}rcp_pat_f64: 102; SI: v_div_scale_f64 103define amdgpu_kernel void @rcp_pat_f64(double addrspace(1)* %out, double %src) #1 { 104 %rcp = fdiv double 1.0, %src 105 store double %rcp, double addrspace(1)* %out, align 8 106 ret void 107} 108 109; FUNC-LABEL: {{^}}unsafe_rcp_pat_f64: 110; SI: v_rcp_f64_e32 [[RESULT:v\[[0-9]+:[0-9]+\]]], s{{\[[0-9]+:[0-9]+\]}} 111; SI-NOT: [[RESULT]] 112; SI: buffer_store_dwordx2 [[RESULT]] 113define amdgpu_kernel void @unsafe_rcp_pat_f64(double addrspace(1)* %out, double %src) #2 { 114 %rcp = fdiv double 1.0, %src 115 store double %rcp, double addrspace(1)* %out, align 8 116 ret void 117} 118 119; FUNC-LABEL: {{^}}safe_rsq_rcp_pat_f64: 120; SI-NOT: v_rsq_f64_e32 121; SI: v_sqrt_f64 122; SI: v_rcp_f64 123define amdgpu_kernel void @safe_rsq_rcp_pat_f64(double addrspace(1)* %out, double %src) #1 { 124 %sqrt = call double @llvm.sqrt.f64(double %src) 125 %rcp = call double @llvm.amdgcn.rcp.f64(double %sqrt) 126 store double %rcp, double addrspace(1)* %out, align 8 127 ret void 128} 129 130; FUNC-LABEL: {{^}}unsafe_rsq_rcp_pat_f64: 131; SI: v_rsq_f64_e32 [[RESULT:v\[[0-9]+:[0-9]+\]]], s{{\[[0-9]+:[0-9]+\]}} 132; SI-NOT: [[RESULT]] 133; SI: buffer_store_dwordx2 [[RESULT]] 134define amdgpu_kernel void @unsafe_rsq_rcp_pat_f64(double addrspace(1)* %out, double %src) #2 { 135 %sqrt = call double @llvm.sqrt.f64(double %src) 136 %rcp = call double @llvm.amdgcn.rcp.f64(double %sqrt) 137 store double %rcp, double addrspace(1)* %out, align 8 138 ret void 139} 140 141attributes #0 = { nounwind readnone } 142attributes #1 = { nounwind "unsafe-fp-math"="false" "denormal-fp-math-f32"="preserve-sign,preserve-sign" } 143attributes #2 = { nounwind "unsafe-fp-math"="true" "denormal-fp-math-f32"="preserve-sign,preserve-sign" } 144attributes #3 = { nounwind "unsafe-fp-math"="false" "denormal-fp-math-f32"="ieee,ieee" } 145attributes #4 = { nounwind "unsafe-fp-math"="true" "denormal-fp-math-f32"="ieee,ieee" } 146 147!0 = !{float 2.500000e+00} 148