diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2017-03-25 19:41:17 +0300 |
---|---|---|
committer | Steffen Klassert <steffen.klassert@secunet.com> | 2017-03-27 07:04:14 +0200 |
commit | 6c786bcb29dd684533ec165057f437d5bb34a4b2 (patch) | |
tree | f185635c44186df8b31a7991ac26366a9fbd0481 /net/xfrm | |
parent | e1b0048e18d4637603cf6f43b9b24345abdeec5c (diff) | |
download | op-kernel-dev-6c786bcb29dd684533ec165057f437d5bb34a4b2.zip op-kernel-dev-6c786bcb29dd684533ec165057f437d5bb34a4b2.tar.gz |
xfrm: branchless addr4_match() on 64-bit
Current addr4_match() code has special test for /0 prefixes because of
standard required undefined behaviour. However, it is possible to omit
it on 64-bit because shifting can be done within a 64-bit register and
then truncated to the expected value (which is 0 mask).
Implicit truncation by htonl() fits nicely into R32-within-R64 model
on x86-64.
Space savings: none (coincidence)
Branch savings: 1
Before:
movzx eax,BYTE PTR [rdi+0x2a] # ->prefixlen_d
test al,al
jne xfrm_selector_match + 0x23f
...
movzx eax,BYTE PTR [rbx+0x2b] # ->prefixlen_s
test al,al
je xfrm_selector_match + 0x1c7
After (no branches):
mov r8d,0x20
mov rdx,0xffffffffffffffff
mov esi,DWORD PTR [rsi+0x2c]
mov ecx,r8d
sub cl,BYTE PTR [rdi+0x2a]
xor esi,DWORD PTR [rbx]
mov rdi,rdx
xor eax,eax
shl rdi,cl
bswap edi
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'net/xfrm')
0 files changed, 0 insertions, 0 deletions