Created
February 1, 2013 16:32
-
-
Save maxdeliso/4692401 to your computer and use it in GitHub Desktop.
restrict in c99
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
| WITHOUT RESTRICT: | |
| $ echo "void frob(unsigned char* first, unsigned char* second, unsigned int count) { | |
| for(int i = 0; i < count; ++i ) { | |
| first[i] = second[i]; | |
| } | |
| }" | clang -cc1 -O3 -S -x c -std=c99 - | |
| _frob: | |
| testl %edx, %edx | |
| je LBB0_2 | |
| LBB0_1: | |
| movb (%rsi), %al | |
| movb %al, (%rdi) | |
| incq %rsi | |
| incq %rdi | |
| decl %edx | |
| jne LBB0_1 | |
| LBB0_2: | |
| ret | |
| WITH RESTRICT: | |
| $ echo "void frob(unsigned char* restrict first, unsigned char* restrict second, unsigned int count) { | |
| for(int i = 0; i < count; ++i ) { | |
| first[i] = second[i]; | |
| } | |
| }" | clang -cc1 -O3 -S -x c -std=c99 - | |
| .align 4, 0x90 | |
| _frob: | |
| pushq %rax | |
| testl %edx, %edx | |
| je LBB0_2 | |
| decl %edx | |
| incq %rdx | |
| callq _memcpy | |
| LBB0_2: | |
| popq %rax | |
| ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment