[LLVMbugs] [Bug 13204] New: Optimization pass to combine sin, cos library calls to sincos
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Jun 25 08:06:01 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=13204
Bug #: 13204
Summary: Optimization pass to combine sin, cos library calls to
sincos
Product: libraries
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Transformation Utilities
AssignedTo: unassignedbugs at nondot.org
ReportedBy: drewm1980 at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
On gcc, when calls to both sin() and cos() math library calls are present, the
get optimized to a single call to sincos().
Here is a newsgroup thread with a small benchmark:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-September/043234.html
I checked a quick code snippet:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char **argv) {
float x = *(float*) argv[0];
return (int) sinf(x) + cosf(x) + sinf(x) + cosf(x);
}
in the online demo, and this still seems to be the case in clang 3:
.Ltmp2:
.cfi_def_cfa_offset 16
movq (%rsi), %rax
movss (%rax), %xmm0
movss %xmm0, (%rsp) # 4-byte Spill
callq cosf
movss %xmm0, 4(%rsp) # 4-byte Spill
movss (%rsp), %xmm0 # 4-byte Reload
callq sinf
cvttss2si %xmm0, %eax
cvtsi2ss %eax, %xmm1
movss 4(%rsp), %xmm2 # 4-byte Reload
addss %xmm2, %xmm1
addss %xmm0, %xmm1
addss %xmm2, %xmm1
cvttss2si %xmm1, %eax
popq %rdx
ret
Adding support for sincos, sincosf, sincosl might boost performance of
trig-heavy numerical codes, i.e. codes involving a lot of coordinate
transformations, i.e. dynamic equations for robotic systems.
Apologies in advance if I'm submitting this to the wrong component; I'm very
much just an end user. Thanks!
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list