summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2020-06-25 14:05:09 -0700
committerThiago Macieira <thiago.macieira@intel.com>2022-11-28 10:59:20 -0800
commit99c7f0419e66692260be56c0385badeacb3f6760 (patch)
treeae8d1b032bb36c72c102f99d64fda35a9fdedbbb /src/corelib/kernel
parent21950e3085bd45dbd4b55fb76e3d47319cbb11d7 (diff)
qfloat16: add support for native _Float16 (C2x extended floating point)
The C++ equivalent is std::float16_t, defined in P1467[1], and is coming with GCC 13 both in native mode (for x86, using AVX512FP16) and in emulated mode. The C and C++ types will be the same type (<stdfloat> simply typedefs). qfloat16 will need to remain a wrapper with an integer member to keep ABI with previous Qt versions. Because it is a trivially-copyable small type, it gets currently passed in registers; the presence of the integer member means it gets passed in general-purpose registers, while a single _Float16 member would be passed in a floating-point register. See: https://gcc.godbolt.org/z/8fEendjff [1] https://wg21.link/p1467 Change-Id: I8a5b6425b64a4e319b94fffd161be56397cb48e6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qmath.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h
index fd39f46c1b..b1e5b4f17e 100644
--- a/src/corelib/kernel/qmath.h
+++ b/src/corelib/kernel/qmath.h
@@ -113,7 +113,7 @@ class QHypotHelper
public:
QHypotHelper(T first) : scale(qAbs(first)), total(1) {}
T result() const
- { return qIsFinite(scale) ? scale > 0 ? scale * T(std::sqrt(total)) : T(0) : scale; }
+ { return qIsFinite(scale) ? scale > 0 ? scale * T(qSqrt(total)) : T(0) : scale; }
template<typename F, typename ...Fs>
auto add(F first, Fs... rest) const
@@ -133,7 +133,7 @@ public:
return QHypotHelper<R>(scale, total);
if (val > scale) {
const R ratio = scale / next;
- return QHypotHelper<R>(val, total * ratio * ratio + 1);
+ return QHypotHelper<R>(val, total * ratio * ratio + R(1));
}
const R ratio = next / scale;
return QHypotHelper<R>(scale, total + ratio * ratio);