VisualStudio - __fastcall instead of __cdecl?

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
mar
Posts: 1970
Joined: Fri Nov 26, 2010 1:00 pm
Location: Czech Republic
Full name: Martin Sedlak

VisualStudio - __fastcall instead of __cdecl?

Post by mar » Mon Jun 18, 2012 5:28 pm

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

User avatar
Jim Ablett
Posts: 1327
Joined: Fri Jul 14, 2006 5:56 am
Location: London, England
Contact:

Re: VisualStudio - __fastcall instead of __cdecl?

Post by Jim Ablett » Mon Jun 18, 2012 6:36 pm

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.

User avatar
rvida
Posts: 481
Joined: Thu Apr 16, 2009 10:00 am
Location: Slovakia, EU

Re: VisualStudio - __fastcall instead of __cdecl?

Post by rvida » Mon Jun 18, 2012 6:51 pm

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

mar
Posts: 1970
Joined: Fri Nov 26, 2010 1:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: VisualStudio - __fastcall instead of __cdecl?

Post by mar » Mon Jun 18, 2012 9:45 pm

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

mar
Posts: 1970
Joined: Fri Nov 26, 2010 1:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: VisualStudio - __fastcall instead of __cdecl?

Post by mar » Mon Jun 18, 2012 9:47 pm

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

Post Reply