;; Copyright (c) 2020-2025, Intel Corporation ;; ;; SPDX-License-Identifier: BSD-3-Clause define(`WIDTH',`64') define(`ISA',`AVX512SKX') ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; half precision rcp and rsqrt using native SPR instriuctions ;; they will be invoked only when hardware support is available. declare <8 x half> @llvm.x86.avx512fp16.mask.rcp.sh(<8 x half>, <8 x half>, <8 x half>, i8) define half @__rcp_uniform_half(half) nounwind readonly alwaysinline { %vec = insertelement <8 x half> undef, half %0, i32 0 %rcp = tail call <8 x half> @llvm.x86.avx512fp16.mask.rcp.sh(<8 x half> %vec, <8 x half> %vec, <8 x half> undef, i8 -1) %ret = extractelement <8 x half> %rcp, i32 0 ret half %ret } declare <32 x half> @llvm.x86.avx512fp16.mask.rcp.ph.512(<32 x half>, <32 x half>, i32) define <64 x half> @__rcp_varying_half(<64 x half>) nounwind readonly alwaysinline { %vec1 = shufflevector <64 x half> %0, <64 x half> undef, <32 x i32> %vec2 = shufflevector <64 x half> %0, <64 x half> undef, <32 x i32> %rcp1 = tail call <32 x half> @llvm.x86.avx512fp16.mask.rcp.ph.512(<32 x half> %vec1, <32 x half> undef, i32 -1) %rcp2 = tail call <32 x half> @llvm.x86.avx512fp16.mask.rcp.ph.512(<32 x half> %vec2, <32 x half> undef, i32 -1) %ret = shufflevector <32 x half> %rcp1, <32 x half> %rcp2, <64 x i32> ret <64 x half> %ret } declare <8 x half> @llvm.x86.avx512fp16.mask.rsqrt.sh(<8 x half>, <8 x half>, <8 x half>, i8) define half @__rsqrt_uniform_half(half) nounwind readnone alwaysinline { %vec = insertelement <8 x half> undef, half %0, i32 0 %rsqrt = tail call <8 x half> @llvm.x86.avx512fp16.mask.rsqrt.sh(<8 x half> %vec, <8 x half> %vec, <8 x half> undef, i8 -1) %ret = extractelement <8 x half> %rsqrt, i32 0 ret half %ret } declare <32 x half> @llvm.x86.avx512fp16.mask.rsqrt.ph.512(<32 x half>, <32 x half>, i32) define <64 x half> @__rsqrt_varying_half(<64 x half>) nounwind readnone alwaysinline { %vec1 = shufflevector <64 x half> %0, <64 x half> undef, <32 x i32> %vec2 = shufflevector <64 x half> %0, <64 x half> undef, <32 x i32> %rsqrt1 = tail call <32 x half> @llvm.x86.avx512fp16.mask.rsqrt.ph.512(<32 x half> %vec1, <32 x half> undef, i32 -1) %rsqrt2 = tail call <32 x half> @llvm.x86.avx512fp16.mask.rsqrt.ph.512(<32 x half> %vec2, <32 x half> undef, i32 -1) %ret = shufflevector <32 x half> %rsqrt1, <32 x half> %rsqrt2, <64 x i32> ret <64 x half> %ret }