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
| C:\temp>cl /O2 /nologo /FAs test.cpp | |
| test.cpp | |
| C:\temp>test | |
| 0000000000000001 | |
| 0000000100000000 |
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
| ; Listing generated by Microsoft (R) Optimizing Compiler Version 16.00.40219.01 | |
| TITLE C:\temp\test.cpp | |
| .686P | |
| .XMM | |
| include listing.inc | |
| .model flat | |
| INCLUDELIB LIBCMT | |
| INCLUDELIB OLDNAMES | |
| PUBLIC ?f@@YA_KH@Z ; f | |
| ; Function compile flags: /Ogtpy | |
| ; File c:\temp\test.cpp | |
| ; COMDAT ?f@@YA_KH@Z | |
| _TEXT SEGMENT | |
| _n$ = 8 ; size = 4 | |
| ?f@@YA_KH@Z PROC ; f, COMDAT | |
| ; 8 : return __ll_lshift(1ull, n); | |
| mov ecx, DWORD PTR _n$[esp-4] | |
| mov eax, 1 | |
| xor edx, edx | |
| shld edx, eax, ecx | |
| shl eax, ecx | |
| ; 9 : } | |
| ret 0 | |
| ?f@@YA_KH@Z ENDP ; f | |
| _TEXT ENDS | |
| PUBLIC ?g@@YA_KH@Z ; g | |
| EXTRN __allshl:PROC | |
| ; Function compile flags: /Ogtpy | |
| ; COMDAT ?g@@YA_KH@Z | |
| _TEXT SEGMENT | |
| _n$ = 8 ; size = 4 | |
| ?g@@YA_KH@Z PROC ; g, COMDAT | |
| ; 13 : return 1ull << n; | |
| mov ecx, DWORD PTR _n$[esp-4] | |
| mov eax, 1 | |
| xor edx, edx | |
| jmp __allshl | |
| ?g@@YA_KH@Z ENDP ; g | |
| _TEXT ENDS | |
| PUBLIC ??_C@_09MAJGPEFC@?$CF016I64x?6?$AA@ ; `string' | |
| PUBLIC _main | |
| EXTRN _printf:PROC | |
| ; COMDAT ??_C@_09MAJGPEFC@?$CF016I64x?6?$AA@ | |
| CONST SEGMENT | |
| ??_C@_09MAJGPEFC@?$CF016I64x?6?$AA@ DB '%016I64x', 0aH, 00H ; `string' | |
| ; Function compile flags: /Ogtpy | |
| CONST ENDS | |
| ; COMDAT _main | |
| _TEXT SEGMENT | |
| _main PROC ; COMDAT | |
| ; 18 : printf("%016I64x\n", f(32)); | |
| xor ecx, ecx | |
| mov eax, 1 | |
| shld ecx, eax, 32 | |
| push ecx | |
| shl eax, 32 ; 00000020H | |
| push eax | |
| push OFFSET ??_C@_09MAJGPEFC@?$CF016I64x?6?$AA@ | |
| call _printf | |
| ; 19 : printf("%016I64x\n", g(32)); | |
| push 1 | |
| push 0 | |
| push OFFSET ??_C@_09MAJGPEFC@?$CF016I64x?6?$AA@ | |
| call _printf | |
| add esp, 24 ; 00000018H | |
| ; 20 : return 0; | |
| xor eax, eax | |
| ; 21 : } | |
| ret 0 | |
| _main ENDP | |
| _TEXT ENDS | |
| END |
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
| #include <stdio.h> | |
| #include <intrin.h> | |
| #pragma intrinsic(__ll_lshift) | |
| unsigned long long f(int n) | |
| { | |
| return __ll_lshift(1ull, n); | |
| } | |
| unsigned long long g(int n) | |
| { | |
| return 1ull << n; | |
| } | |
| int main() | |
| { | |
| printf("%016I64x\n", f(32)); | |
| printf("%016I64x\n", g(32)); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment