
9 Aug
2010
9 Aug
'10
10:02 p.m.
On Tuesday 10 August 2010 03:06:46, MAN wrote:
I believe the improvement was in avoiding the call to 'sqrt', rather than substituting (^2) by a mult.
That's the big one. sqrt is pretty expensive compared to a multiplication.
Although that last substitution is always welcomed in C, GHC could easily make it for you.
It could, but it doesn't (at least not in core). Most of the time it doesn't make a significant difference whether you use (x ^ 2) or (x * x), but sometimes it can make a big difference (we had an example earlier this year, but I can't seem to find it now).