From 5c54b53299d0223877158df6285560b7a69609ff Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Sat, 16 Apr 2011 08:24:15 -0700 Subject: Use explicit division avoidance in print_decimal. --- printf.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/printf.c b/printf.c index b67d7da..c982353 100644 --- a/printf.c +++ b/printf.c @@ -14,8 +14,16 @@ static int print_decimal(unsigned long val) { do { - *--p = (val % 10) + '0'; - val /= 10; + unsigned long d, r; + + /* Compiling with -Os results in a call to the division routine. + Do what the compiler ought to have done. */ + d = __builtin_alpha_umulh(val, 0xcccccccccccccccd); + d >>= 3; + r = val - (d * 10); + + *--p = r + '0'; + val = d; } while (val); } -- cgit v1.1