Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Question about warning C4740

New Contributor I
[bash] warning C4740: flow in or out of inline asm code suppresses global optimization[/bash]
This error is a little ambiguous: What is the scope of the suppression? I'm assuming it just means "cannot include this function in global optimization", but on the other hand, the builds are so fast when this error pops up that I get the impression they were suppressed for the entire link.
(Which is annoying, since the debug version of this library is compiled with global optimization enabled too, forcing the link to start over with /LTCG only to then appear not to actually do global optimization)
0 Kudos
2 Replies
Here is the explaination for C4740:

Compiler Warning (Level 4) C4740

Error Message

flow in or out of inline asm code suppresses global optimization

When there is a jump in to or out of an asm block, global optimizations are disabled for that function.

The following sample generates C4740:

// C4740.cpp

// compile with: /O2 /W4

// processor: x86

int main() {

__asm jmp tester


0 Kudos
I can really only speak to the Intel compiler here, so I'm not sure what Microsoft's compiler is exactly disabling, but most "global" optimizations (for example mod/ref aliasing analysis)are unable to work with such a structure, and since any such optimization requires a global scope to work (hence why it's a global optimization), the existence of such a construct precludes it from occuring where flow information is necessary.

And in fact, this kind of construct also hinders some globaloptimizations that just occur across basic blocks, so it's not justinterprocedural globaloptimizations that are going to be affected. The basic takeawayis that if you have such a construct and can re-code it so that the code doesn't use them, better performance is quite possible.

0 Kudos