builtin llvm.fma

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)

Tia.

Reed

I was wondering something similar recently. Why doesn’t clang provide a math.h that emits the llvm math intrinsics instead of calls to the libc functions? For #include <math.h> double foo(double y) { return exp(y); } I get a call to an external function instead of llvm.exp.f64

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