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

David Blaikie dblaikie at gmail.com
Wed Nov 7 08:24:09 PST 2012


Adding Lang Hames who implemented fpcontract in LLVM and Clang & might
know what's going on here.

On Wed, Nov 7, 2012 at 12:08 AM, Anitha Boyapati
<anitha.boyapati at gmail.com> wrote:
> 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
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>



More information about the cfe-dev mailing list