aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJim Mussared2019-10-09 22:59:35 +1100
committerDamien George2019-10-10 17:39:32 +1100
commit580a2656d10cc7c1fc93e094d7eb71f04d99c329 (patch)
treed90ef3d7eeae092414b9de089522088e9fcd2deb /lib
parent305f537bf940fbbe3474cd1e0938586426d25b48 (diff)
stm32: Use hardware double sqrt on F7/H7 MCUs.
Identical to cd527bb324ade952d11a134859d38bf5272c165e but for doubles. This gives a -2.754% improvement on bm_float.py, and -35% improvement on calling sqrt in a loop.
Diffstat (limited to 'lib')
-rw-r--r--lib/libm_dbl/thumb_vfp_sqrt.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/libm_dbl/thumb_vfp_sqrt.c b/lib/libm_dbl/thumb_vfp_sqrt.c
new file mode 100644
index 000000000..dd37a07b0
--- /dev/null
+++ b/lib/libm_dbl/thumb_vfp_sqrt.c
@@ -0,0 +1,10 @@
+// an implementation of sqrt for Thumb using hardware double-precision VFP instructions
+
+double sqrt(double x) {
+ double ret;
+ asm volatile (
+ "vsqrt.f64 %P0, %P1\n"
+ : "=w" (ret)
+ : "w" (x));
+ return ret;
+}