cookedm@physics.mcmaster.ca (David M. Cooke) writes:
Tim Hochberg <tim.hochberg@cox.net> writes:
We may want to reconsider this at least partially. I tried implementing a few 1-argument functions two way. First as a table lookup and second using a dedicated opcode. The first gave me a speedup of almost 60%, but the latter gave me a speedup of 100%. The difference suprised me, but I suspect it's do to the fact that the x86 supports some functions directly, so the function call gets optimized away for sin and cos just as it does for +-*/. That implies that some functions should get there own opcodes, while others are not worthy.
Yeah, I was going to stare at the assembly output from gcc before deciding.
Note that some functions that are supported directly by the CPU may still be a function call because they aren't good enough.
... and a quick test shows me that with gcc 4 under linux, only sqrt is inlined (and it does a test for NaN (I think) and calls the C library sqrt on that). On PowerPC under OS X, even sqrt is a function call. -- |>|\/|< /--------------------------------------------------------------------------\ |David M. Cooke http://arbutus.physics.mcmaster.ca/dmc/ |cookedm@physics.mcmaster.ca