http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59385

            Bug ID: 59385
           Summary: gcc 4.9 fails to use fma with
                    __attribute__((target("fma")))
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jtaylor.debian at googlemail dot com

attached code does not emit fma instructions in gcc 4.9 while it did in gcc-4.8
(ffast-math is enabled):

$ gcc -v
COLLECT_GCC=/scratch/jtaylor/gcc/local-trunk/bin//gcc
COLLECT_LTO_WRAPPER=/scratch/jtaylor/gcc/local-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /media/jtaylor/external1/buildacc/gcc-trunk/configure
--enable-languages=c,c++,fortran --enable-tls
--prefix=/scratch/jtaylor/gcc/local-trunk --with-gmp=/usr --with-mpfr=/usr
--with-mpc=/usr --with-cloog=/usr --with-ppl=/usr --with-isl=/usr
Thread model: posix
gcc version 4.9.0 20131204 (experimental) (GCC) 

$ gcc-4.9 -Wall fma-attribute.c -c -std=c99 -O2 && objdump -d fma-attribute.o 

fma-attribute.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <f>:
   0:    c5 fb 10 06              vmovsd (%rsi),%xmm0
   4:    c5 fb 59 02              vmulsd (%rdx),%xmm0,%xmm0
   8:    c5 fb 58 01              vaddsd (%rcx),%xmm0,%xmm0
   c:    c5 fb 11 07              vmovsd %xmm0,(%rdi)
  10:    c3                       retq   

whereas gcc 4.8.1 does:

COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.8.1-10ubuntu9' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.8 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin
--with-system-zlib --disable-browser-plugin --enable-java-awt=gtk
--enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre
--enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu9) 

$ gcc-4.8 -Wall fma-attribute.c -c -std=c99 -O2 && objdump -d fma-attribute.o 

0000000000000000 <f>:
   0:    c5 fb 10 06              vmovsd (%rsi),%xmm0
   4:    c5 fb 10 09              vmovsd (%rcx),%xmm1
   8:    c4 e2 f1 99 02           vfmadd132sd (%rdx),%xmm1,%xmm0
   d:    c5 fb 11 07              vmovsd %xmm0,(%rdi)
  11:    c3                       retq   
  12:    66 66 66 66 66 2e 0f     data32 data32 data32 data32 nopw
%cs:0x0(%rax,%rax,1)
  19:    1f 84 00 00 00 00 00 


another weirdness is that gcc 4.8 and 4.9 it uses fma/avx also for the function
marked target("sse"), this can be fixed by only setting it in the declaration
and not the definition. Is that intentional?

Reply via email to