views:

74

answers:

2

I set VC++ to generate ASM for a method which calls sqrt, to see if it's generating FPU or SSE instructions. However when sqrt is called, I don't see the ASM. I only see a call to some function __CIsqrt, which I assume is some system sqrt function. I can't see any ASM for that to know what it is doing?

+5  A: 

That's because the compiler isn't generating the code - the code already exists in the library. If you want to see it, the easiest method is often to trace into the library function call in the debugger in assembler mode.

anon
THat would only be the case for DLL functions? If statically linked I'd expect to see the code? Or is it a limitation with the ASM generated.If nothing else, does this prove sqrt is not being inlined in my case?
John
@John It's nothing to do with DLLs or statics - a library is a library - the code exists in the library at the other end of the function call. It certainly proves sqrt is not being inlined, but I wouldn't expect it to be.
anon
+2  A: 

The math functions are implemented in a library. The library contains the FPU/SSE2 instructions but additional code is needed to implement the /fp compile option. While most CRT code is available as source code in the vc\crt\src subdirectory of the VS install directory, that's not the case for the math functions. It is written by Intel, they probably didn't permit the source to be published. The library is located in vc\crt\src\intel\mt_lib\tran.lib. At a megabyte, far too much to ever consider disassembling.

If you want to see the assembly, you should build your project with /MT and step into the function with the debugger.

Hans Passant