Files
clang-p2996/llvm/test/CodeGen/DirectX/rsqrt.ll
Farzon Lotfi 8f9ee39c58 [HLSL] Implement rsqrt intrinsic (#84820)
This change implements #70074
- `hlsl_intrinsics.h` - add the `rsqrt` api
- `DXIL.td` add the llvm intrinsic to DXIL op lowering map.
- `Builtins.td` - add an hlsl builtin for rsqrt.
- `CGBuiltin.cpp` add the ir generation for the rsqrt intrinsic.
- `SemaChecking.cpp` - reuse the one arg float only  checks.
- `IntrinsicsDirectX.td` -add an `rsqrt` intrinsic.
2024-03-14 16:49:33 -04:00

29 lines
883 B
LLVM

; RUN: opt -S -dxil-op-lower < %s | FileCheck %s
; Make sure dxil operation function calls for rsqrt are generated for float and half.
; CHECK-LABEL: rsqrt_float
; CHECK: call float @dx.op.unary.f32(i32 25, float %{{.*}})
define noundef float @rsqrt_float(float noundef %a) {
entry:
%a.addr = alloca float, align 4
store float %a, ptr %a.addr, align 4
%0 = load float, ptr %a.addr, align 4
%dx.rsqrt = call float @llvm.dx.rsqrt.f32(float %0)
ret float %dx.rsqrt
}
; CHECK-LABEL: rsqrt_half
; CHECK: call half @dx.op.unary.f16(i32 25, half %{{.*}})
define noundef half @rsqrt_half(half noundef %a) {
entry:
%a.addr = alloca half, align 2
store half %a, ptr %a.addr, align 2
%0 = load half, ptr %a.addr, align 2
%dx.rsqrt = call half @llvm.dx.rsqrt.f16(half %0)
ret half %dx.rsqrt
}
declare half @llvm.dx.rsqrt.f16(half)
declare float @llvm.dx.rsqrt.f32(float)