[cfe-dev] builtin llvm.fma

Tobias Grosser tobias at grosser.es
Fri Aug 30 17:29:49 PDT 2013


On 08/30/2013 03:33 PM, reed kotler wrote:
> What C code would you use to get the following intrinsics to be emitted?
>
> declare float     @llvm.pow.f32(float  %Val, float %Power)
> declare double    @llvm.pow.f64(double %Val, double %Power)

This works for me.

$ cat test.c
#include <math.h>
double foo(double y, double a) { return pow(y, a); }

$ clang -S -emit-llvm -o - test.c -ffast-math -O3
; ModuleID = 'test.c'
target datalayout = 
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

; Function Attrs: nounwind readonly uwtable
define double @foo(double %y, double %a) #0 {
   %1 = tail call double @llvm.pow.f64(double %y, double %a)
   ret double %1
}

; Function Attrs: nounwind readonly
declare double @llvm.pow.f64(double, double) #1


Cheers,
Tobias



More information about the cfe-dev mailing list