[LLVMdev] llvm builtins

reed kotler rkotler at mips.com
Wed Feb 4 15:39:39 PST 2015


In the following example with gcc style builtins, in once case 
llvm.powi.f64 is emitted
and in the other just a call to library function powf.

  ~/llvm/build/Debug+Asserts/bin/clang -S -emit-llvm pow1.c

Why is that?

Is there a way to force the call to an llvm style builtin?

Tia.

Reed
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pow1.c
Type: text/x-csrc
Size: 269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150204/b600c9bd/attachment.c>
-------------- next part --------------
; ModuleID = 'pow1.c'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@f = global float 0x4007333340000000, align 4
@g = global float 0x40139999A0000000, align 4
@i = global i32 10, align 4
@fresult1 = common global float 0.000000e+00, align 4
@fresult2 = common global float 0.000000e+00, align 4
@.str = private unnamed_addr constant [7 x i8] c"%f %f\0A\00", align 1

; Function Attrs: nounwind uwtable
define void @fpowf() #0 {
entry:
  %0 = load float* @f, align 4
  %1 = load float* @g, align 4
  %call = call float @powf(float %0, float %1) #2
  store float %call, float* @fresult1, align 4
  ret void
}

; Function Attrs: nounwind readnone
declare float @powf(float, float) #1

; Function Attrs: nounwind uwtable
define void @fpowi() #0 {
entry:
  %0 = load float* @f, align 4
  %conv = fpext float %0 to double
  %1 = load i32* @i, align 4
  %2 = call double @llvm.powi.f64(double %conv, i32 %1)
  %conv1 = fptrunc double %2 to float
  store float %conv1, float* @fresult2, align 4
  ret void
}

; Function Attrs: nounwind readnone
declare double @llvm.powi.f64(double, i32) #2

; Function Attrs: nounwind uwtable
define i32 @main() #0 {
entry:
  %retval = alloca i32, align 4
  store i32 0, i32* %retval
  call void @fpowf()
  call void @fpowi()
  %0 = load float* @fresult1, align 4
  %conv = fpext float %0 to double
  %1 = load float* @fresult2, align 4
  %conv1 = fpext float %1 to double
  %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([7 x i8]* @.str, i32 0, i32 0), double %conv, double %conv1)
  ret i32 0
}

declare i32 @printf(i8*, ...) #3

attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind readnone "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #2 = { nounwind readnone }
attributes #3 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }

!llvm.ident = !{!0}

!0 = metadata !{metadata !"clang version 3.6.0 (trunk)"}


More information about the llvm-dev mailing list