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:<br>
<br>typedef float t;<br>t foo(t a, t b)<br>{<br> return a*b;<br>}<br><br>this gets compiled into (msp430 asm, arm does the same):<br> call #__mulsf3<br> ret<br><br>but if we instead do "return b*a;" we get:<br>
push.w r11<br> push.w r10<br> mov.w r14, r11<br> mov.w r15, r10<br> mov.w r13, r15<br> mov.w r12, r14<br> mov.w r10, r13<br> mov.w r11, r12<br> call #__mulsf3<br> pop.w r10<br>
pop.w r11<br> ret<br><br>Notice the arguments are getting swapped for a commutable operation were there order shouldn't matter. Just an idea to push the optimizations further.<br>