From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7254 invoked by alias); 29 Apr 2013 16:44:16 -0000 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 Received: (qmail 7210 invoked by uid 48); 29 Apr 2013 16:44:13 -0000 From: "tejohnson at google dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/44578] GCC generates MMX instructions but fails to generate "emms" Date: Mon, 29 Apr 2013 16:44:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: tejohnson at google dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 X-SW-Source: 2013-04/txt/msg02358.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44578 Teresa Johnson changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tejohnson at google dot com --- Comment #7 from Teresa Johnson 2013-04-29 16:44:10 UTC --- *** Update on below text: As of r198401 the problem is hidden unless compiling with -mtune=athlon64 due to some tuning changes. *** I have another instance of this issue. Trunk is generating move instructions to implement an inlined memcpy. The move instructions use the MMX registers, but no EMMS instruction is generated. My testcase then calls a libm function that uses the FPU, which returns incorrect results. This worked with an older gcc 4.7 based compiler, which didn't use MMX registers. The compiler was configured for x86_64-unknown-linux-gnu. The testcase was compiled with -O2. $ cat test.cc #include #include #include #include namespace { volatile double dd = 0.080553657784353652; double dds, ddc; } unsigned long long test(float num) { if (num < 0) { num = 0; } unsigned int i; memcpy(&i, &num, sizeof(unsigned int)); unsigned long long a = i; sincos(dd, &dds, &ddc); if (isnan(dds) || isnan(ddc)) { printf ("Failed\n"); exit (1); } return a; } $ cat test_main.cc #include extern unsigned long long test(float num); int main() { unsigned long long h = test(1); printf ("Passed\n"); } $ g++ -O2 test*.cc -mtune=athlon64 (See earlier note on why -mtune=athlon64 is needed here) $ a.out Failed