[cfe-dev] Clang and llvm IR - Generate FMA

Anitha Boyapati anitha.boyapati at gmail.com
Wed Nov 7 00:08:42 PST 2012


I am trying to generate FMA for X86 target ("bdver2") through
-ffp-contract=fast. [Sanity checks: bdver2 supports fma]

While I am able to generate FMA for  "C" input, I could not when LLVM IR is
input. Example illustrated below:

#input - C file
float test(float a, float b, float c) {
        return a*b+c;
The below arguments work fine -

$clang -march=bdver2 -mfma -ffp-contract=fast -S test.c

However, when I input the below llvm assembly(pasted at the end), clang
(not llc) fails to generate FMA. Any idea why and how I will be able to do
that through clang?

$ clang -march=bdver2 -ffp-contract=fast -mfma -S test.ll -O3
$ more test.s

test:                                   # @test
# BB#0:                                 # %entry
        vmulss  %xmm1, %xmm0, %xmm0
        vaddss  %xmm2, %xmm0, %xmm0
        .size   test, .Ltmp0-test

; ModuleID = 'test.c'
target datalayout =
target triple = "x86_64-unknown-linux-gnu"
module asm "\09.ident\09\22GCC: (GNU) 4.7.2 LLVM: 3.2svn\22"
define float @test(float %a, float %b, float %c) nounwind uwtable readnone {
  %0 = fmul float %a, %b
  %1 = fadd float %0, %c
  ret float %1

* Anitha*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121107/0eed01fc/attachment.html>

More information about the cfe-dev mailing list