Commit 675cf53c authored by Rasmus Villemoes's avatar Rasmus Villemoes Committed by Linus Torvalds

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: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Tejun Heo <tj@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent cdb1dc3f
...@@ -165,9 +165,9 @@ static const u16 decpair[100] = { ...@@ -165,9 +165,9 @@ static const u16 decpair[100] = {
/* /*
* This will print a single '0' even if r == 0, since we would * This will print a single '0' even if r == 0, since we would
* immediately jump to out_r where two 0s would be written and one of * immediately jump to out_r where two 0s would be written but only
* them then discarded. This is needed by ip4_string below. All other * one of them accounted for in buf. This is needed by ip4_string
* callers pass a non-zero value of r. * below. All other callers pass a non-zero value of r.
*/ */
static noinline_for_stack static noinline_for_stack
char *put_dec_trunc8(char *buf, unsigned r) char *put_dec_trunc8(char *buf, unsigned r)
...@@ -206,9 +206,7 @@ char *put_dec_trunc8(char *buf, unsigned r) ...@@ -206,9 +206,7 @@ char *put_dec_trunc8(char *buf, unsigned r)
out_r: out_r:
/* 1 <= r < 100 */ /* 1 <= r < 100 */
*((u16 *)buf) = decpair[r]; *((u16 *)buf) = decpair[r];
buf += 2; buf += r < 10 ? 1 : 2;
if (buf[-1] == '0')
buf--;
return buf; return buf;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment