From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17454 invoked by alias); 3 May 2012 18:02:27 -0000 Received: (qmail 17439 invoked by uid 22791); 3 May 2012 18:02:26 -0000 X-SWARE-Spam-Status: No, hits=-3.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 03 May 2012 18:02:13 +0000 From: "tydeman at tybor dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tydeman at tybor dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-05/txt/msg00318.txt.bz2 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 #include #include 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