Created
April 5, 2017 08:54
-
-
Save merryhime/0c381a6ff5a4a01df476591f351d8af7 to your computer and use it in GitHub Desktop.
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
std::uint32_t duplicate(std::uint32_t o) { | |
return ((o & 0x80808080) >> 7) * 0xFF; | |
} | |
# compiler suggestion: | |
duplicate(unsigned int): | |
shr edi, 7 | |
and edi, 16843009 | |
mov eax, edi | |
shl eax, 8 | |
sub eax, edi | |
ret | |
# hand optimized: | |
duplicate(unsigned int): | |
and edi, 0x80808080 | |
mov eax, edi | |
shr edi, 7 | |
sub eax, edi | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment