Problem with functions not inlining

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Greg Strong
Posts: 388
Joined: Sun Dec 21, 2008 6:57 pm
Location: Washington, DC

Re: Problem with functions not inlining

Post by Greg Strong »

wgarvin wrote:I reproduced this with VC Express 2008 and the test code you pasted (and /arch:SSE2 and intrinsics enabled). With the Release build, I got generated code almost identical to what you pasted.

I'm not sure why, but when I disable exceptions (Configuration Properties > Code Generation > Enable C++ Exceptions) then it does use the SSE2 instructions right in the TEST function. So unless you need them, I suggest turning that off (which is generally a good idea anyway unless you are going to use them). I've never used C++ exceptions with SSE2 stuff, so I'm not sure what is going on here.

Also, turning off the "Buffer Security Check" on the same page might be worth doing.
Wow! That did it! I can't imagine what exeception handling has to do with inlining, but the assembler output for my pawn structure eval looks much, much smaller. Looks like lots of optimizations weren't working beyond the problem with not inlining. I can't wait to run some tests! I'll post a follow-up to let anyone who's interested know how it works out. I'll also post my super-special SEE2 pawn structure code as soon as I'm sure it's working correctly.

Thanks, everyone, for all your help!!!
User avatar
Bo Persson
Posts: 243
Joined: Sat Mar 11, 2006 8:31 am
Location: Malmö, Sweden
Full name: Bo Persson

Re: Problem with functions not inlining

Post by Bo Persson »

Greg Strong wrote:
wgarvin wrote:I reproduced this with VC Express 2008 and the test code you pasted (and /arch:SSE2 and intrinsics enabled). With the Release build, I got generated code almost identical to what you pasted.

I'm not sure why, but when I disable exceptions (Configuration Properties > Code Generation > Enable C++ Exceptions) then it does use the SSE2 instructions right in the TEST function. So unless you need them, I suggest turning that off (which is generally a good idea anyway unless you are going to use them). I've never used C++ exceptions with SSE2 stuff, so I'm not sure what is going on here.

Also, turning off the "Buffer Security Check" on the same page might be worth doing.
Wow! That did it! I can't imagine what exeception handling has to do with inlining, but the assembler output for my pawn structure eval looks much, much smaller. Looks like lots of optimizations weren't working beyond the problem with not inlining. I can't wait to run some tests! I'll post a follow-up to let anyone who's interested know how it works out. I'll also post my super-special SEE2 pawn structure code as soon as I'm sure it's working correctly.

Thanks, everyone, for all your help!!!
There is a connection between exceptions and inlining - when you inline a function you lose the context for running destructors during stack unwinding.

As the SSE2 intrinsics can't possibly throw any C++ exception, it's a bit buggy anyway.