Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Fastcall and inline functions optimization bug in VC++?

Author: Marcus Heidkamp

Date: 00:41:47 01/15/02

Go up one level in this thread


On January 14, 2002 at 12:56:55, Bo Persson wrote:

>On January 14, 2002 at 04:39:15, Marcus Heidkamp wrote:
>
>>To some Visual C++ 6 experts:
>>
>>I tried to write a function that used the __fastcall calling convention so that
>>function arguments will be provided in edx and ecx registers rather than pushing
>>those onto the stack. Further, I wanted that function to be inlined. So far so
>>good.
>>But as I rewrote the function body in inline assembler, the compiler did not
>>provide the function parameters anymore! VC++ thought, the arguments were not
>>referenced in the function. Because they should already be in edx/ecx there is
>>no need to explicitly load them from the parameter list into a register using
>>assembler. So the compiler simply "optimized" the code by not initializing the
>>registers with the appropriate values when calling the function.
>>
>>The only workarounds I found so far are the following:
>>1) Don't do __fastcall.
>>2) Don't do inline assembler
>>3) Turn off global optimization for that function.
>>But that is not what I want.
>>
>>Has anyone experienced the same, and is there a good solution for this? E.g. can
>>I tell the compiler somehow, that those parameters are not explicitly, but
>>implicitly used?
>>
>>Thanks in advance.
>>
>>Marcus
>
>I have tried this too, but not found any good way of doing it. I ended up with
>option 1).
>
>BTW, have you noticed that using inline assembly also interferes with the
>compiler's optimizations for any C code in the same function? Any gain by using
>assembly might be lost in other code being worse...
>
>Bo Persson
>bop2@telia.com

I am not surprised of that. Actually the compiler does not know what you're
doing in the _asm part within a function, so there is no way the compiler can do
it's best. Therefore, I wanted to use the __fastcall inline AND assembler stuff.
I wanted the whole function to be in asm, but it ended up with the problems
described above.

Marcus




This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.