On Mon, Dec 7, 2009 at 2:29 PM, bearophile <[email protected]> wrote: > Lars T. Kyllingstad: >> I also seem to remember someone (was it Don or bearophile, perhaps?) >> listing various optimisation possibilities that are more readily >> available if ^^ is a built-in operator. > > It was Don, I think. > Those optimizations can be done with the pow, ipow and cpow (real, integer, > complex, this is just an idea) functions too. GCC for example simplifies > cases when the exponent is 2 or 3 (that are the most common): > > // C code > #include "stdio.h" > #include "math.h" > #include "stdlib.h" > > int main() { > int x = atoi("100"); > printf("%f\n", pow(x, 2)); > return 0; > } > > Compiled with: > gcc version 4.3.3-dw2-tdm-1 (GCC) > gcc -Wall -S -O3 test2.c -o test2.s > > ... > call _atoi > pushl %eax > fildl (%esp) > addl $4, %esp > fmul %st(0), %st > movl $LC1, (%esp) > fstpl 4(%esp) > call _printf > ... > > Some weeks ago I have filed a bug asking for a similar optimization in LLVM > too (so LDC too will have it).
Holy smokes! You actually file bugs in the LLVM database?! --bb
