diff options
author | Rasmus Villemoes <linux@rasmusvillemoes.dk> | 2015-04-16 15:43:42 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-17 09:03:55 -0400 |
commit | 675cf53c1deaffadc7b6a0b4afe6cdafec86bedb (patch) | |
tree | ecf7d3a546cdc560b5946b73b6163a5a20b500fc /lib | |
parent | cdb1dc3f1ca5c5899e5fa186afe20390bd8c00dc (diff) |
lib/vsprintf.c: improve put_dec_trunc8 slightly
I hadn't had enough coffee when I wrote this. Currently, the final
increment of buf depends on the value loaded from the table, and
causes gcc to emit a cmov immediately before the return. It is smarter
to let it depend on r, since the increment can then be computed in
parallel with the final load/store pair. It also shaves 16 bytes of
.text.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Tejun Heo <tj@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vsprintf.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index c93ec8a035b3..da39c608a28c 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -165,9 +165,9 @@ static const u16 decpair[100] = { | |||
165 | 165 | ||
166 | /* | 166 | /* |
167 | * This will print a single '0' even if r == 0, since we would | 167 | * This will print a single '0' even if r == 0, since we would |
168 | * immediately jump to out_r where two 0s would be written and one of | 168 | * immediately jump to out_r where two 0s would be written but only |
169 | * them then discarded. This is needed by ip4_string below. All other | 169 | * one of them accounted for in buf. This is needed by ip4_string |
170 | * callers pass a non-zero value of r. | 170 | * below. All other callers pass a non-zero value of r. |
171 | */ | 171 | */ |
172 | static noinline_for_stack | 172 | static noinline_for_stack |
173 | char *put_dec_trunc8(char *buf, unsigned r) | 173 | char *put_dec_trunc8(char *buf, unsigned r) |
@@ -206,9 +206,7 @@ out_q: | |||
206 | out_r: | 206 | out_r: |
207 | /* 1 <= r < 100 */ | 207 | /* 1 <= r < 100 */ |
208 | *((u16 *)buf) = decpair[r]; | 208 | *((u16 *)buf) = decpair[r]; |
209 | buf += 2; | 209 | buf += r < 10 ? 1 : 2; |
210 | if (buf[-1] == '0') | ||
211 | buf--; | ||
212 | return buf; | 210 | return buf; |
213 | } | 211 | } |
214 | 212 | ||