Page 1 of 1

VisualStudio - __fastcall instead of __cdecl?

Posted: Mon Jun 18, 2012 7:28 pm
by mar
Hi,
I just made my program ~3% faster, perhaps more (nothing to do with chess) by forcing the compiler to use __fastcall instead of the default __cdecl.
I wonder whether using __fastcall would have the same effect with PGO enabled.
Could someone verify this? I believe it may be a nice speedup for the windows build of a chess engine, if it would hold with PGO.
It may but it may not. I especially wonder what compiler experts have to say about it ;)

Martin

Re: VisualStudio - __fastcall instead of __cdecl?

Posted: Mon Jun 18, 2012 8:36 pm
by Jim Ablett
Hi Martin,

I read about this optimization tip many years ago from Dann Corbit and use it whenever possible with Msvc
although I found it produces instability with some chess engine code, so you must be careful. If I used with Intel, binary would always crash or become unstable.

http://www.playwitharena.com/?Tips_%2B_ ... r_Binaries

Jim.

Re: VisualStudio - __fastcall instead of __cdecl?

Posted: Mon Jun 18, 2012 8:51 pm
by rvida
mar wrote:Hi,
I just made my program ~3% faster, perhaps more (nothing to do with chess) by forcing the compiler to use __fastcall instead of the default __cdecl.
I wonder whether using __fastcall would have the same effect with PGO enabled.
Could someone verify this? I believe it may be a nice speedup for the windows build of a chess engine, if it would hold with PGO.
It may but it may not. I especially wonder what compiler experts have to say about it ;)

Martin
Hi,

Just in case you didn't already know - this option is ignored for 64bit builds. The x64 ABI defines only one calling convention, __fastcall.

http://msdn.microsoft.com/en-us/library/ms235286.aspx


Richard

Re: VisualStudio - __fastcall instead of __cdecl?

Posted: Mon Jun 18, 2012 11:45 pm
by mar
Jim Ablett wrote:Hi Martin,

I read about this optimization tip many years ago from Dann Corbit and use it whenever possible with Msvc
although I found it produces instability with some chess engine code, so you must be careful. If I used with Intel, binary would always crash or become unstable.

http://www.playwitharena.com/?Tips_%2B_ ... r_Binaries

Jim.
That's interesting Jim, I only noticed some compile time problems with libpng and tremor where some callback function ptrs were explicitly declared as __cdecl and thus incompatible with __fastcall, didn't know about stability issues though. I guess I'll be happy with cdecl then. Thanks for clarifying this to me.

Martin

Re: VisualStudio - __fastcall instead of __cdecl?

Posted: Mon Jun 18, 2012 11:47 pm
by mar
rvida wrote: Hi,

Just in case you didn't already know - this option is ignored for 64bit builds. The x64 ABI defines only one calling convention, __fastcall.

http://msdn.microsoft.com/en-us/library/ms235286.aspx


Richard
Thanks Richard I didn't know that. It seems logical though because as far as I understand 64-bit mode has more registers available than x86 mode. Thanks for the insight.

Martin