<mathimf.h> 2X slower than <math.h> ?!?!

<mathimf.h> 2X slower than <math.h> ?!?!

Hi all,

I tried to replace with , hoping that it may speed things up, but thats not at all what happened. The code is now more than 2X slower?!?!

Are there some issues that one needs to be aware of before using ?

Also, I am coding from VC8.0. Which is selected during compilation? The Microsoft one?

Thanks in advance.


5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I'm not aware of any particular issues. If you post a small example where you're seeing such a problem we could investigate.


Ok, so a small self-contained example is attached. It is a very simple image processing routine. With , it takes 0.10 sec on my P4 running WinXP. With , it takes 0.62 sec.

6X slower!!!!!!! I would really appreciate if anybody could tell me what is going on!

I've compiled from VC++ 8.0 with the fastest options. Here is the whole command line for the compiler:

/GL /c /O3 /Og /Ob2 /Oi /Ot /Oy /GA /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /FD /MD /GS /GR /Fo"Release/" /W3 /nologo /Wp64 /Zi /Gd /Qansi-alias /QaxP /QxP

and for the linker

/LTCG kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /OUT:"D:CodeOptimisationRelease/Optimisation.exe" /INCREMENTAL:NO /nologo /TLBID:1 /DEBUG /PDB:"D:CodeOptimisationReleaseOptimisation.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /IMPLIB:"D:CodeOptimisationReleaseOptimisation.lib" /MACHINE:X86 /MANIFEST /MANIFESTFILE:"ReleaseOptimisation.exe.interme

Thanks in advance,



Downloadtext/x-c++src binary4.cpp4.84 KB

Including mathimf.h can be problematic, and I would not recommend it. For instance, I find that including it disables all vectorization of trig functions (issue
if you have access). I also saw the slowdown in my scientific code. I've found it best to just link to libmmd.lib and use math.h. If you need a special function included in mathimf.h, it is best to just import it.


Yes, it seems that including "mathimf.h" in this case prevents calling of the excellent SVML (Short Vector Math Library) routines that are called with "math.h",

00401222 movups xmm0,xmmword ptr [ebx+edi*4]

00401226 call ___svml_logf4 (40CD84h)

0040122B call ___svml_tanhf4 (40CDBCh)

00401230 call ___svml_expf4 (40CDE4h)

00401235 mov eax,dword ptr [esp+2Ch]

00401239 movaps xmmword ptr [esi+edi*4],xmm0

0040123D add edi,4

00401240 cmp edi,eax

00401242 jb main+222h (401222h)

Best Regards,

Lars Petter Endresen

Leave a Comment

Please sign in to add a comment. Not a member? Join today