From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18001 invoked by alias); 8 Dec 2014 15:08:13 -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 17939 invoked by uid 48); 8 Dec 2014 15:08:05 -0000 From: "bernie.ogden at linaro dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/64225] New: -funsafe-math-optimizations generates call to pow where multiply instruction would do Date: Mon, 08 Dec 2014 15:08: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-Version: 4.9.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bernie.ogden at linaro dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-12/txt/msg00761.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64225 Bug ID: 64225 Summary: -funsafe-math-optimizations generates call to pow where multiply instruction would do Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: bernie.ogden at linaro dot org Created attachment 34217 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34217&action=edit Reproducer Running e.g. ./gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux/bin/aarch64-linux-gnu-gcc -S -o - r.i -O1 -funsafe-math-optimizations generates code like this: stp x29, x30, [sp, -32]! add x29, sp, 0 str d8, [sp, 16] fmov d8, d0 fmov d1, 2.0e+0 bl pow fmul d8, d8, d8 ldr d0, .LC0 fmul d0, d8, d0 ldr d8, [sp, 16] ldp x29, x30, [sp], 32 ret Removing -funsafe-math-optimizations, or replacing it with -ffast-math, replaces the call to pow with the intuitively more sensible fmul and saves the stacking, e.g.: ldr d1, .LC0 fmul d1, d0, d1 fmul d0, d1, d0 ret A little experimentation shows similar behaviour for AArch32, AArch64 and x86. By binary chopping through Linaro releases I find the behaviour begins with the first 4.8 release (gcc version 4.8.1 20130401 (prerelease)). Attached r.i and the output generated by: ./gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux/bin/aarch64-linux-gnu-gcc -v --save-temps -S -o - r.c -O1 -funsafe-math-optimizations > output 2>&1 Guessed middle-end for Component, and entered latest version in which I've seen the bug for Version.