public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "tydeman at tybor dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/53216] New: fmaf() alters rounding mode of sse2 FPU Date: Thu, 03 May 2012 18:02:00 -0000 [thread overview] Message-ID: <bug-53216-4@http.gcc.gnu.org/bugzilla/> (raw) 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
next reply other threads:[~2012-05-03 18:02 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-05-03 18:02 tydeman at tybor dot com [this message] 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-53216-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).