xref: /aosp_15_r20/external/llvm/test/CodeGen/AMDGPU/llvm.AMDGPU.rsq.clamped.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=VI -check-prefix=FUNC %s
3*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=r600 -mcpu=cypress -verify-machineinstrs < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Worker; FIXME: Uses of this should be moved to llvm.amdgcn.rsq.clamped, and
6*9880d681SAndroid Build Coastguard Worker; an r600 variant added.
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Workerdeclare float @llvm.AMDGPU.rsq.clamped.f32(float) nounwind readnone
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Worker; FUNC-LABEL: {{^}}rsq_clamped_f32:
11*9880d681SAndroid Build Coastguard Worker; SI: v_rsq_clamp_f32_e32
12*9880d681SAndroid Build Coastguard Worker
13*9880d681SAndroid Build Coastguard Worker; VI-DAG: v_rsq_f32_e32 [[RSQ:v[0-9]+]], {{s[0-9]+}}
14*9880d681SAndroid Build Coastguard Worker; VI-DAG: v_min_f32_e32 [[MIN:v[0-9]+]], 0x7f7fffff, [[RSQ]]
15*9880d681SAndroid Build Coastguard Worker; TODO: this constant should be folded:
16*9880d681SAndroid Build Coastguard Worker; VI-DAG: v_mov_b32_e32 [[MINFLT:v[0-9]+]], 0xff7fffff
17*9880d681SAndroid Build Coastguard Worker; VI: v_max_f32_e32 {{v[0-9]+}}, [[MIN]], [[MINFLT]]
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker; EG: RECIPSQRT_CLAMPED
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Workerdefine void @rsq_clamped_f32(float addrspace(1)* %out, float %src) nounwind {
22*9880d681SAndroid Build Coastguard Worker  %rsq_clamped = call float @llvm.AMDGPU.rsq.clamped.f32(float %src) nounwind readnone
23*9880d681SAndroid Build Coastguard Worker  store float %rsq_clamped, float addrspace(1)* %out, align 4
24*9880d681SAndroid Build Coastguard Worker  ret void
25*9880d681SAndroid Build Coastguard Worker}
26