[cfe-dev] question about fused multiply add and Clang GNU modes

Ana Pazos via cfe-dev cfe-dev at lists.llvm.org
Fri Sep 18 13:52:57 PDT 2015


Hi folks,

 

GNU GCC allows fused multiply add instruction generation in -std=gnu* modes
(default  mode in GCC) on both ARM 32-bit and 64-bit targets. See outputs
below.

 

Clang 3.8 defaults to gnu11 for C programs, according to
http://clang.llvm.org/docs/UsersManual.html#c-language-features  and
function  CompilerInvocation::setLangDefaults in
./lib/Frontend/CompilerInvocation.cpp in the Clang source code.

 

So why  fp-contract=fast is not made default in Clang as it is done in GNU
GCC?

 

Just trying to understand the rationale behind this decision. We know the
instruction  produces results with higher precision and compliant to IEEE
754 standard.

 

This difference in default behavior in Clang/LLVM compared to GNU GCC is a
performance disadvantage.

 

Thanks!

Ana.

 

$ cat t.c

double f(double a, double b)

{

return b*b+a*a;

}

 

$ gcc-linaro-4.9-2015.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc
-S -O3 -o- -std=c99 t.c

        .cpu generic+fp+simd

        .file   "t.c"

        .text

        .align  2

        .global f

        .type   f, %function

f:

        fmul    d1, d1, d1

        fmul    d0, d0, d0

        fadd    d0, d1, d0

        ret

        .size   f, .-f

        .ident  "GCC: (Linaro GCC 4.9-2015.05) 4.9.3 20150413 (prerelease)"

        .section        .note.GNU-stack,"",%progbits

$ gcc-linaro-4.9-2015.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc
-S -O3 -o- -std=gnu99 t.c

        .cpu generic+fp+simd

        .file   "t.c"

        .text

        .align  2

        .global f

        .type   f, %function

f:

        fmul    d0, d0, d0

        fmadd   d0, d1, d1, d0

        ret

        .size   f, .-f

        .ident  "GCC: (Linaro GCC 4.9-2015.05) 4.9.3 20150413 (prerelease)"

        .section        .note.GNU-stack,"",%progbits

$ gcc-linaro-4.9-2015.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc
-S -O3 -o-  t.c

        .cpu generic+fp+simd

        .file   "t.c"

        .text

        .align  2

        .global f

        .type   f, %function

f:

        fmul    d0, d0, d0

        fmadd   d0, d1, d1, d0

        ret

        .size   f, .-f

        .ident  "GCC: (Linaro GCC 4.9-2015.05) 4.9.3 20150413 (prerelease)"

        .section        .note.GNU-stack,"",%progbits

 

 

Ana Pazos
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, 
a Linux Foundation Collaborative Project.



 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150918/e99699fb/attachment.html>


More information about the cfe-dev mailing list