Linked by Thom Holwerda on Wed 17th Nov 2010 23:10 UTC, submitted by Debjit
Internet Explorer There's a bit of a ruckus on the web about how Microsoft was supposedly cheating when it comes to Internet Explorer 9's performance on benchmarks. Digitizor, as well as some enterprising readers over at HackerNews, came to the conclusion that Microsoft included code in IE9 specifically to ace the SunSpider benchmark. I was ready to write a scathing article about this, - until I loaded up the IEBlog. As it turns, it's not cheating, it's not a bug - it's an actual piece of smart code optimisation other browsers don't have yet.
Permalink for comment 450753
To read all comments associated with this story, please click here.
RE[3]: Of Course.
by draburn on Mon 22nd Nov 2010 00:10 UTC in reply to "RE[2]: Of Course."
Member since:

Given the fact that at least as far as I can see, this is strictly a compile time optimization (even if it being done by JIT), the compiler can't really notice that:
for (count=0;count<x;count++); y+=count
... is dead code when x=0 (resulting in y=y), as long as x isn't constant (read: calculated or given as input).

Well, it can notice that,
- given x <= 1, the loop is dead code (noop)
- given x > 1, the whole loop is equivalent to: y += x*(x-1)/2.

Hence, a really good compiler should probably replace the loop by a proper
if (x>1) y += x*(x-1)/2

Edit: what I'm trying to prove here is that, when different compiler optimizations start to work together, the results can be amazing and really difficult to predict. Put it in other way, you don't need *bad* code nor a silly programmer to produce code that can be significantly optimized...

Edited 2010-11-22 00:14 UTC

Reply Parent Score: 1