Archived

This topic is now archived and is closed to further replies.

Prozak

Weird Code generated by Visual Studio

Recommended Posts

Some fancy speedup technique? I was having a look at the diferent code VS7 generates for a simple function call, and a function pointer to that same function. sqrt - dummy square root function, takes a UINT, returns UINT rv - return value, a UINT fptr - UINT(*fptr)(UINT) a function pointer, points to sqrt In the blue box you can see the weird code. The 2nd line basicly does nothing, because eax''s value hasn''t changed... Is this some fancy optimization routine for opcode pipelines or something (i know assembly, but i dont know the recent opcodes very well, like mmx and sse, and the best ways to optimise for those)...

[Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD][Yann L.][Enginuity]
The most irrefutable evidence that there is intelligent life in the Universe is that they haven''t contacted us!

Share this post


Link to post
Share on other sites
Considering there''s that __RTC_CheckEsp in there, I''m guessing this is a debug build with runtime checks enabled. Debug builds have horribly unoptimized code. This particular instance could be either from a naive code generation, part of the runtime checks or necessary for the debug symbols to match up. Or something else entirely.

Share this post


Link to post
Share on other sites
Yes, i forgot to mention this is DEBUG code, sorry, should have put that in there.
Even then... its kinda weird none the less...


[Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD][Yann L.][Enginuity]
The most irrefutable evidence that there is intelligent life in the Universe is that they haven''t contacted us!

Share this post


Link to post
Share on other sites
Yup, it is wierd, but this is exactly something that a peephole optimizer will get rid of, and probably, fixing the compiler such that it never actually outputs that assembly will be problematic. This could be for many reasons, but generally debug code is useless when it comes to analyzing the quality of compiler generated code.

Share this post


Link to post
Share on other sites