From 29adaeb2c0e795e75044a9b678b8cc66570f7e95 Mon Sep 17 00:00:00 2001 From: Alexander Monakov Date: Mon, 6 Jan 2020 20:31:47 +0300 Subject: [PATCH] math: move i386 sqrtf to C with inline asm --- src/math/i386/sqrtf.c | 12 ++++++++++++ src/math/i386/sqrtf.s | 7 ------- 2 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 src/math/i386/sqrtf.c delete mode 100644 src/math/i386/sqrtf.s diff --git a/src/math/i386/sqrtf.c b/src/math/i386/sqrtf.c new file mode 100644 index 00000000..41c65c2b --- /dev/null +++ b/src/math/i386/sqrtf.c @@ -0,0 +1,12 @@ +#include + +float sqrtf(float x) +{ + long double t; + /* The long double result has sufficient precision so that + * second rounding to float still keeps the returned value + * correctly rounded, see Pierre Roux, "Innocuous Double + * Rounding of Basic Arithmetic Operations". */ + __asm__ ("fsqrt" : "=t"(t) : "0"(x)); + return (float)t; +} diff --git a/src/math/i386/sqrtf.s b/src/math/i386/sqrtf.s deleted file mode 100644 index 9e944f45..00000000 --- a/src/math/i386/sqrtf.s +++ /dev/null @@ -1,7 +0,0 @@ -.global sqrtf -.type sqrtf,@function -sqrtf: flds 4(%esp) - fsqrt - fstps 4(%esp) - flds 4(%esp) - ret -- 2.25.1