This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/52593] Builtin sqrt on x86 is not correctly rounded
- From: "bugdal at aerifal dot cx" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 16 Mar 2012 14:23:09 +0000
- Subject: [Bug target/52593] Builtin sqrt on x86 is not correctly rounded
- Auto-submitted: auto-generated
- References: <bug-52593-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52593
--- Comment #6 from Rich Felker <bugdal at aerifal dot cx> 2012-03-16 14:23:09 UTC ---
The 387 FPU ensures correct rounding for the currently selected precision mode,
which per the ABI is always extended precision.
As for the usefulness of fixing this, I found the bug while working on my
correct sqrt implementation in musl libc, because despite the existence of a
correct version of the function, I was still getting wrong results. It turned
out gcc was replacing it with a buggy builtin. I don't think "glibc gets it
wrong anyway" is a reason not to fix the problem, especially now that glibc
seems to be under new maintainership and actually fixing longstanding WONTFIX
bugs.
Folks who just care about speed and want to throw correctness away should
already be using -ffast-math and similar.
Actually since this bug is rounding-related, perhaps it would suffice to make
-frounding-math turn off the builtin sqrt when using 387 math...?