summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qjsonarray.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2024-03-01 11:12:20 -0800
committerThiago Macieira <thiago.macieira@intel.com>2024-03-12 18:23:20 -0700
commitc86e1758dda16852f81ec542713ae09ec0779fc1 (patch)
tree5b236e1efec5e1d346e857b3fd568d820aff57ca /src/corelib/serialization/qjsonarray.cpp
parent45fd36f1480a6229879a4e59236ffa1d1d22dfbf (diff)
convertDoubleTo<FP>: add support for x86 intrinsics
The x86 SSE instructions do what we want and set a flag in the MXCSR to indicate whether we should return false, so we can improve the codegen. GCC generates for QStringView::toFloat(): call _ZNK11QStringView8toDoubleEPb movl $8064, 12(%rsp) movl $1, %eax #APP # 330 "/home/tjmaciei/src/qt/qt6/qtbase/src/corelib/global/qnumeric_p.h" 1 vldmxcsr 12(%rsp) vcvtsd2ss %xmm0, %xmm0, %xmm0 vstmxcsr 12(%rsp) # 0 "" 2 #NO_APP movl 12(%rsp), %edx testb $24, %dl je .L2120 ... handling of the under/overflow ... The MXCSR instructions do need to read and write from memory, but the stack is usually already in L1 and CPUs have special optimizations for it. There are two alternative implementations to the implementation chosen: first, we could confirm there was no underflow or overflow using an expression like: (v == 0) == (*value == 0) && qt_is_finite(v) == qt_is_finite(*value); But that is still very costly, with 4 UCOMISx instructions and several memory loads. Second, we could use the VFPCLASSSD and VFPCLASSSS (yes, 4 "S") instructions to confirm whether a finite input became zero or non- finite, but a) that's only available with AVX512, so of little practical use today and b) it has a 3-cycle latency. Like the comparisons above, we'd need 4 of them. Change-Id: I01ec3c774d9943adb903fffd17b8b9cb2ce805ce Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/serialization/qjsonarray.cpp')
0 files changed, 0 insertions, 0 deletions