================
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// 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() {
+  // SPIR-V doesn't support llvm.canonicalize. Synthesize a subnormal by 
halving
+  // the smallest normal. If subnormals are not supported it will flush to +0.
+  half smallest_normal = 0x1p-14h;
+  half sub =
+      smallest_normal * 0.5h; // Expected 0x1p-15h (subnormal) if supported
+  return !__builtin_isfpclass(sub, __FPCLASS_POSZERO);
+}
+#endif // cl_khr_fp16
+
+_CLC_DEF bool __clc_fp32_subnormals_supported() {
+  // SPIR-V doesn't support llvm.canonicalize. Synthesize a subnormal by 
halving
+  // the smallest normal. If subnormals are not supported it will flush to +0.
+  float smallest_normal = 0x1p-126f;
+  float sub =
----------------
arsenm wrote:

Don't need multiply, and I think this logic should be inverted. Denormal 
support is the base case, DAZ is an aberration. i.e., this is what I did in 
device-libs is about
`is_daz() { return __builtin_isfpclass(__builtin_canonicalizef(0x1p-149f), 
__FPCLASS_POSZERO) }`

https://github.com/llvm/llvm-project/pull/157633
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to