Akira Hatanaka
2012-Apr-27 19:09 UTC
[LLVMdev] complex library functions (creal and cimag)
When I compile this code which includes call to crealf,
$ cat foo1.c
#include <complex.h>
float foo1(complex float z) { return crealf(z); }
clang emits a call to crealf,
$ clang foo1.c -S -o - -O3
foo1: # @foo1
.cfi_startproc
# BB#0: # %entry
jmp crealf # TAILCALL
while gcc does it in two move instructions:
$ gcc foo1.c -S -o -O3
foo1:
.LFB0:
.cfi_startproc
movq %xmm0, -8(%rsp)
movss -8(%rsp), %xmm0
Is this an optimization which is missing in llvm?
Or is it making a deliberate decision not to expand the call to move
instructions?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20120427/056d89ad/attachment.html>
On Fri, Apr 27, 2012 at 12:09 PM, Akira Hatanaka <ahatanak at gmail.com> wrote:> When I compile this code which includes call to crealf, > > $ cat foo1.c > #include <complex.h> > > float foo1(complex float z) { return crealf(z); } > > clang emits a call to crealf, > > $ clang foo1.c -S -o - -O3 > foo1: # @foo1 > .cfi_startproc > # BB#0: # %entry > jmp crealf # TAILCALL > > while gcc does it in two move instructions: > > $ gcc foo1.c -S -o -O3 > foo1: > .LFB0: > .cfi_startproc > movq %xmm0, -8(%rsp) > movss -8(%rsp), %xmm0 > > Is this an optimization which is missing in llvm?Missing optimization. There isn't any reason to avoid inlining the implementation. Probably the simplest place to implement this would be CGBuiltin in clang... -Eli
On Apr 27, 2012, at 2:02 PM, Eli Friedman wrote:> On Fri, Apr 27, 2012 at 12:09 PM, Akira Hatanaka <ahatanak at gmail.com> wrote: >> while gcc does it in two move instructions: >> >> $ gcc foo1.c -S -o -O3 >> foo1: >> .LFB0: >> .cfi_startproc >> movq %xmm0, -8(%rsp) >> movss -8(%rsp), %xmm0 >> >> Is this an optimization which is missing in llvm? > > Missing optimization. There isn't any reason to avoid inlining the > implementation. > > Probably the simplest place to implement this would be CGBuiltin in clang...It would also make sense to handle this in simplifylibcalls. There isn't anything C-specific about this. -Chris