From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21745 invoked by alias); 16 Jan 2012 10:12:07 -0000 Received: (qmail 21737 invoked by uid 22791); 16 Jan 2012 10:12:06 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_CP,TW_FC 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; Mon, 16 Jan 2012 10:11:53 +0000 From: "amker.cheng at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/51867] New: GCC generates inconsistent code for same sources calling builtin calls, like sqrtf Date: Mon, 16 Jan 2012 10:15:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Keywords: X-Bugzilla-Severity: trivial X-Bugzilla-Who: amker.cheng at gmail 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-01/txt/msg01743.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51867 Bug #: 51867 Summary: GCC generates inconsistent code for same sources calling builtin calls, like sqrtf Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: trivial Priority: P3 Component: middle-end AssignedTo: unassigned@gcc.gnu.org ReportedBy: amker.cheng@gmail.com compile following program: ---------------------------------------------- #include int a(float x) { return sqrtf(x); } int b(float x) { return sqrtf(x); } With command: arm-none-eabi-gcc -mthumb -mhard-float -mfpu=fpv4-sp-d16 -mcpu=cortex-m4 -O0 -S a.c -o a.S The generated assembly codes is like: ---------------------------------------------- a: @ args = 0, pretend = 0, frame = 8 @ frame_needed = 1, uses_anonymous_args = 0 push {r7, lr} sub sp, sp, #8 add r7, sp, #0 fsts s0, [r7, #4] flds s15, [r7, #4] fsqrts s15, s15 fcmps s15, s15 fmstat beq .L2 flds s0, [r7, #4] bl sqrtf fcpys s15, s0 .L2: ftosizs s15, s15 fmrs r3, s15 @ int mov r0, r3 add r7, r7, #8 mov sp, r7 pop {r7, pc} .size a, .-a .align 2 .global b .thumb .thumb_func .type b, %function b: @ args = 0, pretend = 0, frame = 8 @ frame_needed = 1, uses_anonymous_args = 0 push {r7, lr} sub sp, sp, #8 add r7, sp, #0 fsts s0, [r7, #4] flds s0, [r7, #4] bl sqrtf fcpys s15, s0 ftosizs s15, s15 fmrs r3, s15 @ int mov r0, r3 add r7, r7, #8 mov sp, r7 pop {r7, pc} .size b, .-b The problem exists on trunk and triggered only by O0 optimization. The problem stands for x86 target too.