public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/53216] New: fmaf() alters rounding mode of sse2 FPU
@ 2012-05-03 18:02 tydeman at tybor dot com
  2012-05-03 19:48 ` [Bug c/53216] " marc.glisse at normalesup dot org
  2012-05-04  9:06 ` rguenth at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: tydeman at tybor dot com @ 2012-05-03 18:02 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53216
           Summary: fmaf() alters rounding mode of sse2 FPU
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: tydeman@tybor.com


The following code shows that the rounding mode of the sse2 FPU is altered by a
call to fmaf().

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

static  float res0, res1, res2, res3;
static  float half = 0.5f;

void chk( void ){
  res2 = res0 + half;        /* should round down to even */
  if( res2 == res0 ){ puts("OK1"); }else{ puts("Bad1"); }
  res3 = res1 + half;        /* should round up to even */
  if( res3 != res1 ){ puts("OK2"); }else{ puts("Bad2"); }
}

int main(void){

  res0 = FLT_EPSILON;
  res0++;
  res0--;
  res0 = 1.f / res0;        /* even; 1/EPSILON is a magic number */
  res1 = res0 + 1.f;        /* odd */

  chk();

  res2 = sinf( 1.f );        /* sse2 rounding is not altered */

  chk();

  res2 = fmaf( 1.f, 1.f, 1.f );    /* this messes up sse2 rounding */

  chk();

  return 0;
}


Hardware:  Intel Core 2 Duo in 32-bit mode
O.S.    :  Fedora Core 17 in 32-bit mode
Compiler:  gcc 4.7.0-2
Library :  glibc 2.15-32

Compiler options: -std=gnu11 -O0 -mfpmath=sse -msse2 -fno-builtin
-frounding-math -mieee-fp -ffloat-store -fexcess-precision=standard


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

* [Bug c/53216] fmaf() alters rounding mode of sse2 FPU
  2012-05-03 18:02 [Bug c/53216] New: fmaf() alters rounding mode of sse2 FPU tydeman at tybor dot com
@ 2012-05-03 19:48 ` marc.glisse at normalesup dot org
  2012-05-04  9:06 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: marc.glisse at normalesup dot org @ 2012-05-03 19:48 UTC (permalink / raw)
  To: gcc-bugs

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

Marc Glisse <marc.glisse at normalesup dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marc.glisse at normalesup
                   |                            |dot org

--- Comment #1 from Marc Glisse <marc.glisse at normalesup dot org> 2012-05-03 19:47:45 UTC ---
This looks like a glibc issue, doesn't it? Or do you see something wrong with
the code gcc produces for this example?


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

* [Bug c/53216] fmaf() alters rounding mode of sse2 FPU
  2012-05-03 18:02 [Bug c/53216] New: fmaf() alters rounding mode of sse2 FPU tydeman at tybor dot com
  2012-05-03 19:48 ` [Bug c/53216] " marc.glisse at normalesup dot org
@ 2012-05-04  9:06 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-05-04  9:06 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-05-04 09:04:33 UTC ---
Indeed.


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

end of thread, other threads:[~2012-05-04  9:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-03 18:02 [Bug c/53216] New: fmaf() alters rounding mode of sse2 FPU tydeman at tybor dot com
2012-05-03 19:48 ` [Bug c/53216] " marc.glisse at normalesup dot org
2012-05-04  9:06 ` rguenth 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).