Thursday, October 2, 2008

VC 2008 needs /Ox

Some of my database test functions picked up that a field read had gone from about 500 clocks to 1700 clocks, when upgrading from VS 2005 to VS 2008. I don't have time to investigate exactly what causes this, but changing the optimization setting from /O2 to /Ox fixes it (and actually makes 2008's code a bit faster than 2005 if I'm not mistaken).

Bottom line: Use /Ox for all release builds. The executable also seems to be smaller. Maybe it's the omission of the frame pointers.. I don't know.

Friday, September 5, 2008

Shameless plug

This is a shameless plug for the GF's artwork. I slapped the website together. Apparently if I say the words Gina Heyer it works better. viva la vida.

Friday, April 18, 2008

A nickel for every for loop

I was reading this short essay by Mike Vanier. At the end he says "if I had a nickel for every time I've written "for (i = 0; i != N; i++)" in C I'd be a millionaire". Hmm.. it looks like some people make a lot more off their for loops. The word 'for' appears 13527 times in the Quake3 source. At one nickel for every for loop, that would earn JC a cool $676.35. woot! He can finally afford that Voodoo 6.

Thursday, March 13, 2008

Bug in x64 optimizer in VS 2005, unfixed in VS 2008

I came across a bug in the x64 optimizer yesterday. By the looks of this connect.microsoft.com item, it looks like it's been there since VS 2005, and it has not been fixed in VS 2008.

I don't understand the bug completely, but it seems to involve sign extension (using movsxd) when it should do unsigned extension of 32-bit integers to 64-bit.

In my specific usage case, I was splitting up the 32-bit integers into their upper and lower halves, by adding an offset of 0x80000000 for the upper half. My workaround was simply to use 0x80000000 - 1 instead of 0x80000000 as an offset. The optimizer ends up generating different code, which happens to be correct.

If you have any sway with MSFT, please get them to fix this bug. I don't know if the voting system on that connect.microsoft.com site works, but maybe it's worth a try.