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

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


Hi,

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
        .cfi_startproc
# BB#0:                                 # %entry
        vmulss  %xmm1, %xmm0, %xmm0
        vaddss  %xmm2, %xmm0, %xmm0
        ret
.Ltmp0:
        .size   test, .Ltmp0-test
        .cfi_endproc



; ModuleID = 'test.c'
target datalayout =
"e-p:64:64:64-S128-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f16:16:16-f32:32:32-f64:64:64-f128:128:128-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
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 {
entry:
  %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