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)"}
Should be fixed in to always use the LLVM builtin in r228240. On Wed, Feb 4, 2015 at 3:39 PM, reed kotler <rkotler at mips.com> wrote:> 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 > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150204/0770eb9b/attachment.html>
I'm at tip of tree: rkotler at ubuntu-rkotler:~/testmips/rt-rk-llvm-tests/tests-c$ ~/llvm/build/Debug+Asserts/bin/clang -S -emit-llvm pow1.c --version clang version 3.6.0 (trunk) Target: x86_64-unknown-linux-gnu Thread model: posix commit 629438448670d1ad6d6345a782f6ca70c625e574 Merge: 7b8a410 56756c4 Author: Reed Kotler <rkotler at mips.com> Date: Tue Feb 3 16:10:57 2015 -0800 Merge branch 'master' into fast-isel-47 commit 56756c43cd588d6f0565746b5aaef366af7b9d19 Author: NAKAMURA Takumi <geek4civic at gmail.com> Date: Tue Feb 3 03:55:06 2015 +0000 Resurrect initializers for NumLoads and NumStores in LoopVectorizationLegali FIXME: Shall they be managed in LAA? git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk at 227940 91177308-0d3 commit 7b8a41067dac7b23d857b3768a44fa9707bde099 Author: Reed Kotler <rkotler at mips.com> Date: Mon Feb 2 19:33:21 2015 -0800 math intrinsics rkotler at ubuntu-rkotler:~/testmips/rt-rk-llvm-tests/tests-c$ ~/llvm/build/Debug+Asserts/bin/clang -S -emit-llvm pow1.c --version clang version 3.6.0 (trunk) Target: x86_64-unknown-linux-gnu Thread model: posix On 02/04/2015 04:23 PM, Reid Kleckner wrote:> Should be fixed in to always use the LLVM builtin in r228240. > > On Wed, Feb 4, 2015 at 3:39 PM, reed kotler <rkotler at mips.com > <mailto:rkotler at mips.com>> wrote: > > 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 > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu> > http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150204/a02199d5/attachment.html>
Sorry. I did not realize you just fixed it today. Thanks! Reed On 02/04/2015 04:23 PM, Reid Kleckner wrote:> Should be fixed in to always use the LLVM builtin in r228240. > > On Wed, Feb 4, 2015 at 3:39 PM, reed kotler <rkotler at mips.com > <mailto:rkotler at mips.com>> wrote: > > 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 > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu> http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
There are a lot of similar builtin issues. I was just giving a single example. Ditto for sqrt, sin, cos, exp, ..... On 02/04/2015 04:23 PM, Reid Kleckner wrote:> Should be fixed in to always use the LLVM builtin in r228240. > > On Wed, Feb 4, 2015 at 3:39 PM, reed kotler <rkotler at mips.com > <mailto:rkotler at mips.com>> wrote: > > 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 > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu> > http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150204/d6b0a2ac/attachment.html>
I think at least the same issue applies to the following: sqrt, sin, cos, exp, exp2, log, log10, log2, fabs, floor, copysign, ceil, trunc, rint, round... On 02/04/2015 04:23 PM, Reid Kleckner wrote:> Should be fixed in to always use the LLVM builtin in r228240. > > On Wed, Feb 4, 2015 at 3:39 PM, reed kotler <rkotler at mips.com > <mailto:rkotler at mips.com>> wrote: > > 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 > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu> > http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150204/26d7dcc5/attachment.html>
In the latest sync from tip of tree this llvm.pow.f32 and f64 works but not any of the other builtins. shouldn't all these gcc __builtin_xxx be mapping to the corresponding llvm ir function, if available? otherwise how do you make C code use the desired llvm IR function? On 02/04/2015 04:23 PM, Reid Kleckner wrote:> Should be fixed in to always use the LLVM builtin in r228240. > > On Wed, Feb 4, 2015 at 3:39 PM, reed kotler <rkotler at mips.com > <mailto:rkotler at mips.com>> wrote: > > 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 > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu> > http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150205/00d0d002/attachment.html>