diff options
author | Joe Perches <joe@perches.com> | 2014-12-04 18:00:48 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-12-09 14:56:41 -0500 |
commit | d148134be51fe05271ec8d47fe8c815bdee2b8e7 (patch) | |
tree | 213553d693669b3c9bbbc3b821e3680db9b33910 /arch/x86/net/bpf_jit_comp.c | |
parent | 57d743a3dec174b8f1fbf53e93ade2fea3d32bd7 (diff) |
x86: bpf_jit_comp: Reduce is_ereg() code size
Use the (1 << reg) & mask trick to reduce code size.
x86-64 size difference -O2 without profiling for various
gcc versions:
$ size arch/x86/net/bpf_jit_comp.o*
text data bss dec hex filename
9266 4 0 9270 2436 arch/x86/net/bpf_jit_comp.o.4.4.new
10042 4 0 10046 273e arch/x86/net/bpf_jit_comp.o.4.4.old
9109 4 0 9113 2399 arch/x86/net/bpf_jit_comp.o.4.6.new
9717 4 0 9721 25f9 arch/x86/net/bpf_jit_comp.o.4.6.old
8789 4 0 8793 2259 arch/x86/net/bpf_jit_comp.o.4.7.new
10245 4 0 10249 2809 arch/x86/net/bpf_jit_comp.o.4.7.old
9671 4 0 9675 25cb arch/x86/net/bpf_jit_comp.o.4.9.new
10679 4 0 10683 29bb arch/x86/net/bpf_jit_comp.o.4.9.old
Signed-off-by: Joe Perches <joe@perches.com>
Tested-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/x86/net/bpf_jit_comp.c')
-rw-r--r-- | arch/x86/net/bpf_jit_comp.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index 3f627345d51c..09e2ceaf13cb 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c | |||
@@ -135,11 +135,11 @@ static const int reg2hex[] = { | |||
135 | */ | 135 | */ |
136 | static inline bool is_ereg(u32 reg) | 136 | static inline bool is_ereg(u32 reg) |
137 | { | 137 | { |
138 | if (reg == BPF_REG_5 || reg == AUX_REG || | 138 | return (1 << reg) & (BIT(BPF_REG_5) | |
139 | (reg >= BPF_REG_7 && reg <= BPF_REG_9)) | 139 | BIT(AUX_REG) | |
140 | return true; | 140 | BIT(BPF_REG_7) | |
141 | else | 141 | BIT(BPF_REG_8) | |
142 | return false; | 142 | BIT(BPF_REG_9)); |
143 | } | 143 | } |
144 | 144 | ||
145 | /* add modifiers if 'reg' maps to x64 registers r8..r15 */ | 145 | /* add modifiers if 'reg' maps to x64 registers r8..r15 */ |