Reputation: 28346
When using Microsoft Visual C++ (not CLI, just standard native C++) does inline assembly cause optimisation to be disabled for the function?
When I checked using IDA, some of the function code outside the block does seem to change, but I'm not sure what the cause is. The function is (relatively) simple, containing bit manipulation and some math, but no external calls.
Other possible causes I could think of are:
Any ideas?
Upvotes: 6
Views: 751
Reputation: 111298
Yes. See the MSDN articles: Optimizing Inline Assembly as well as Advantages of Inline Assembly
From the article:
The presence of an
__asm
block in a function affects optimization in several ways. First, the compiler doesn't try to optimize the__asm
block itself. What you write in assembly language is exactly what you get. Second, the presence of an __asm block affects register variable storage. The compiler avoids enregistering variables across an__asm
block if the register's contents would be changed by the__asm
block. Finally, some other function-wide optimizations will be affected by the inclusion of assembly language in a function.
Upvotes: 13