public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/64225] New: -funsafe-math-optimizations generates call to pow where multiply instruction would do
@ 2014-12-08 15:08 bernie.ogden at linaro dot org
  2014-12-08 15:08 ` [Bug middle-end/64225] " bernie.ogden at linaro dot org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: bernie.ogden at linaro dot org @ 2014-12-08 15:08 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2014-12-10 17:48 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-08 15:08 [Bug middle-end/64225] New: -funsafe-math-optimizations generates call to pow where multiply instruction would do bernie.ogden at linaro dot org
2014-12-08 15:08 ` [Bug middle-end/64225] " bernie.ogden at linaro dot org
2014-12-08 15:16 ` ktkachov at gcc dot gnu.org
2014-12-08 15:20 ` ktkachov at gcc dot gnu.org
2014-12-08 15:24 ` ktkachov at gcc dot gnu.org
2014-12-08 15:30 ` jgreenhalgh at gcc dot gnu.org
2014-12-08 15:36 ` ktkachov at gcc dot gnu.org
2014-12-08 16:56 ` joseph at codesourcery dot com
2014-12-09 12:52 ` rguenth at gcc dot gnu.org
2014-12-09 12:53 ` [Bug middle-end/64225] [4.8/4.9/5 Regression] " rguenth at gcc dot gnu.org
2014-12-09 15:27 ` wschmidt at gcc dot gnu.org
2014-12-09 15:37 ` ktkachov at gcc dot gnu.org
2014-12-09 23:02 ` wschmidt at gcc dot gnu.org
2014-12-09 23:07 ` wschmidt at gcc dot gnu.org
2014-12-10 13:23 ` [Bug middle-end/64225] [4.8/4.9 " rguenth at gcc dot gnu.org
2014-12-10 17:47 ` wschmidt at gcc dot gnu.org
2014-12-10 17:48 ` wschmidt at gcc dot gnu.org

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).