Created
April 20, 2012 17:26
-
-
Save DCoderLT/2430454 to your computer and use it in GitHub Desktop.
MSVC version of the two functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; http://stackoverflow.com/questions/10250419/why-does-gcc-generate-such-radically-different-assembly-for-nearly-the-same-c-co | |
PUBLIC ?fast_trunc_one@@YAHH@Z ; fast_trunc_one | |
; Function compile flags: /Ogtpy | |
_TEXT SEGMENT | |
_i$ = 8 ; size = 4 | |
?fast_trunc_one@@YAHH@Z PROC ; fast_trunc_one | |
; File c:\program files (x86)\microsoft visual studio 10.0\vc\bin\c2.cpp | |
; Line 6 | |
mov eax, DWORD PTR _i$[esp-4] | |
push esi | |
; Line 7 | |
mov esi, eax | |
sar esi, 23 ; 00000017H | |
mov edx, eax | |
and esi, 255 ; 000000ffH | |
and edx, 8388607 ; 007fffffH | |
mov ecx, 150 ; 00000096H | |
sub ecx, esi | |
or edx, 8388608 ; 00800000H | |
; Line 8 | |
and eax, -2147483648 ; 80000000H | |
pop esi | |
; Line 12 | |
test ecx, ecx | |
jns SHORT $LN2@fast_trunc | |
; Line 13 | |
neg ecx | |
shl edx, cl | |
; Line 15 | |
add edx, eax | |
; Line 18 | |
neg eax | |
xor eax, edx | |
; Line 19 | |
ret 0 | |
$LN2@fast_trunc: | |
; Line 15 | |
sar edx, cl | |
add edx, eax | |
; Line 18 | |
neg eax | |
xor eax, edx | |
; Line 19 | |
ret 0 | |
?fast_trunc_one@@YAHH@Z ENDP ; fast_trunc_one | |
_TEXT ENDS | |
PUBLIC ?fast_trunc_two@@YAHH@Z ; fast_trunc_two | |
; Function compile flags: /Ogtpy | |
_TEXT SEGMENT | |
_i$ = 8 ; size = 4 | |
?fast_trunc_two@@YAHH@Z PROC ; fast_trunc_two | |
; Line 24 | |
mov edx, DWORD PTR _i$[esp-4] | |
push esi | |
; Line 25 | |
mov esi, edx | |
sar esi, 23 ; 00000017H | |
mov eax, edx | |
and esi, 255 ; 000000ffH | |
and eax, 8388607 ; 007fffffH | |
mov ecx, 150 ; 00000096H | |
sub ecx, esi | |
or eax, 8388608 ; 00800000H | |
; Line 26 | |
and edx, -2147483648 ; 80000000H | |
pop esi | |
; Line 30 | |
test ecx, ecx | |
jns SHORT $LN2@fast_trunc@2 | |
; Line 31 | |
neg ecx | |
shl eax, cl | |
; Line 33 | |
mov ecx, edx | |
neg ecx | |
xor eax, ecx | |
add eax, edx | |
; Line 37 | |
ret 0 | |
$LN2@fast_trunc@2: | |
; Line 33 | |
sar eax, cl | |
mov ecx, edx | |
neg ecx | |
xor eax, ecx | |
add eax, edx | |
; Line 37 | |
ret 0 | |
?fast_trunc_two@@YAHH@Z ENDP ; fast_trunc_two | |
_TEXT ENDS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment