-
-
Save fritz0705/3808396 to your computer and use it in GitHub Desktop.
x86_64 gcc optimizations
This file contains hidden or 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
#define UNPACK32(buf) ((buf)[0] << 24 | (buf)[1] << 16 | (buf)[2] << 8 | (buf)[3]) | |
int main() { | |
int i; | |
return UNPACK32(&i); | |
} |
This file contains hidden or 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
main: | |
.LFB0: | |
.cfi_startproc | |
pushq %rbp | |
.cfi_def_cfa_offset 16 | |
.cfi_offset 6, -16 | |
movq %rsp, %rbp | |
.cfi_def_cfa_register 6 | |
movl -4(%rbp), %eax | |
movl %eax, %edx | |
sall $24, %edx | |
leaq -4(%rbp), %rax | |
addq $4, %rax | |
movl (%rax), %eax | |
sall $16, %eax | |
orl %eax, %edx | |
leaq -4(%rbp), %rax | |
addq $8, %rax | |
movl (%rax), %eax | |
sall $8, %eax | |
orl %eax, %edx | |
leaq -4(%rbp), %rax | |
addq $12, %rax | |
movl (%rax), %eax | |
orl %edx, %eax | |
popq %rbp | |
.cfi_def_cfa 7, 8 | |
ret | |
.cfi_endproc |
This file contains hidden or 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
main: | |
.LFB0: | |
.cfi_startproc | |
movl -4(%rsp), %edx | |
sall $24, %edx | |
movl (%rsp), %eax | |
sall $16, %eax | |
orl %edx, %eax | |
orl 8(%rsp), %eax | |
movl 4(%rsp), %edx | |
sall $8, %edx | |
orl %edx, %eax | |
ret | |
.cfi_endproc |
This file contains hidden or 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
main: | |
.LFB0: | |
.cfi_startproc | |
movl -4(%rsp), %eax | |
movl (%rsp), %edx | |
sall $24, %eax | |
sall $16, %edx | |
orl %edx, %eax | |
movl 4(%rsp), %edx | |
orl 8(%rsp), %eax | |
sall $8, %edx | |
orl %edx, %eax | |
ret | |
.cfi_endproc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment