[libclc] [libclc] Refine __clc_fp*_subnormals_supported and __clc_flush_denormal_if_not_supported (PR #157633)
Matt Arsenault via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 3 03:00:04 PDT 2025
================
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <clc/internal/clc.h>
+#include <clc/math/clc_subnormal_config.h>
+
+#ifdef cl_khr_fp16
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+_CLC_DEF bool __clc_fp16_subnormals_supported() {
+#ifdef CLC_SPIRV
+ // SPIR-V doesn't support llvm.canonicalize for now.
+ return false;
+#else
+ return !__builtin_isfpclass(__builtin_elementwise_canonicalize(0x1p-24h),
+ __FPCLASS_POSZERO);
+#endif
+}
+#endif // cl_khr_fp16
+
+_CLC_DEF bool __clc_fp32_subnormals_supported() {
+#ifdef CLC_SPIRV
+ // SPIR-V doesn't support llvm.canonicalize for now.
+ return false;
+#else
+ return !__builtin_isfpclass(__builtin_elementwise_canonicalize(0x1p-149f),
+ __FPCLASS_POSZERO);
+#endif
+}
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+_CLC_DEF bool __clc_fp64_subnormals_supported() {
+#ifdef CLC_SPIRV
+ // SPIR-V doesn't support llvm.canonicalize for now.
----------------
arsenm wrote:
Can you just fix that instead of special casing it here? It's not difficult to implement
https://github.com/llvm/llvm-project/pull/157633
More information about the cfe-commits
mailing list