[LLVMdev] Swapping function arguments in libcalls
Borja Ferrer
borja.ferav at gmail.com
Wed Mar 30 12:53:34 PDT 2011
Hello, I don't know if this has ever been discussed or mentioned, it's
something simple so it could have been talked before, forgive me in that
case. The idea is to basically commute/swap function arguments just like in
instructions if it's beneficial, mainly for libcalls. Consider this example:
typedef float t;
t foo(t a, t b)
{
return a*b;
}
this gets compiled into (msp430 asm, arm does the same):
call #__mulsf3
ret
but if we instead do "return b*a;" we get:
push.w r11
push.w r10
mov.w r14, r11
mov.w r15, r10
mov.w r13, r15
mov.w r12, r14
mov.w r10, r13
mov.w r11, r12
call #__mulsf3
pop.w r10
pop.w r11
ret
Notice the arguments are getting swapped for a commutable operation were
there order shouldn't matter. Just an idea to push the optimizations
further.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110330/b17fafe9/attachment.html>
More information about the llvm-dev
mailing list