public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/46080] New: incorrect precision of sqrtf builtin for x87 arithmetic (-mfpmath=387)
@ 2010-10-19  8:55 vincent at vinc17 dot org
  2010-10-19 10:49 ` [Bug target/46080] [4.4/4.5/4.6 Regression] " rguenth at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: vincent at vinc17 dot org @ 2010-10-19  8:55 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46080

           Summary: incorrect precision of sqrtf builtin for x87
                    arithmetic (-mfpmath=387)
           Product: gcc
           Version: 4.4.5
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: vincent@vinc17.org


With -mfpmath=387 (tested on a x86_64 platform), the first sqrtf is computed in
double precision instead of single. On

#include <stdio.h>
#include <math.h>

float x = (float) M_PI;

int main(void)
{
  printf ("%.60f\n", sqrtf(x));
  printf ("%.60f\n", sqrtf(x));
  printf ("%.60f\n", sqrtf(x));
  return 0;
}

I get with various gcc versions (including gcc version 4.6.0 20101009
(experimental) [trunk revision 165234] (Debian 20101009-1)):

$ gcc -Wall -mfpmath=387 bug.c -o bug -lm -O0; ./bug
1.772453875567026715387441981874871999025344848632812500000000
1.772453904151916503906250000000000000000000000000000000000000
1.772453904151916503906250000000000000000000000000000000000000

The bug is also present with -O1 when the sqrtf calls are grouped in a single
printf and disappears if the builtin is disabled with -fno-builtin-sqrtf.

For the first sqrtf, the asm code shows a fsqrt followed by a "call sqrtf"
under some condition, but the condition is not satisfied. The other occurrences
just have a "call sqrtf", which is correct.


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2010-11-16 10:54 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-19  8:55 [Bug target/46080] New: incorrect precision of sqrtf builtin for x87 arithmetic (-mfpmath=387) vincent at vinc17 dot org
2010-10-19 10:49 ` [Bug target/46080] [4.4/4.5/4.6 Regression] " rguenth at gcc dot gnu.org
2010-10-20  1:52 ` vincent at vinc17 dot org
2010-10-20  8:29 ` ubizjak at gmail dot com
2010-10-20  9:39 ` jakub at gcc dot gnu.org
2010-10-20  9:54 ` zimmerma+gcc at loria dot fr
2010-10-20 10:46 ` jakub at gcc dot gnu.org
2010-10-20 23:43 ` vincent at vinc17 dot org
2010-10-20 23:49 ` pinskia at gcc dot gnu.org
2010-10-21 19:26 ` zimmerma+gcc at loria dot fr
2010-10-21 20:56 ` jakub at gcc dot gnu.org
2010-10-22  6:56 ` zimmerma+gcc at loria dot fr
2010-10-26 13:41 ` jakub at gcc dot gnu.org
2010-11-12 14:35 ` rguenth at gcc dot gnu.org
2010-11-16 10:56 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).