public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Denys Vlasenko <vda.linux@googlemail.com>
To: Michal Nazarewicz <mina86@mina86.com>
Cc: linux-kernel@vger.kernel.org, m.nazarewicz@samsung.com,
	"Douglas W. Jones" <jones@cs.uiowa.edu>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 2/3] lib: vsprintf: optimised put_dec() for 32-bit machines
Date: Fri, 6 Aug 2010 07:18:38 +0200	[thread overview]
Message-ID: <201008060718.38345.vda.linux@googlemail.com> (raw)
In-Reply-To: <0543dae0f66ba8e0ce42ce3adf1fe31704eb240d.1280872240.git.mina86@mina86.com>

On Friday 06 August 2010 00:38, Michal Nazarewicz wrote:
> The disadvantage is that the proposed function is 2.5-3.5 bigger.
> Those are not big functions though -- we are talking here about
> proposed function being below 512.

It's a slippery slope. Here's where it ends: glibc
has memcpy() function which is "only" 8k of code or so.
I'm not joking.



> +#if BITS_PER_LONG == 64
> +
...  
> +#else
...
> +/*
> + * Based on code by Douglas W. Jones found at
> + * <http://www.cs.uiowa.edu/~jones/bcd/decimal.html#sixtyfour>.  This
> + * performs no 64-bit division and hence should be faster on 32-bit
> + * machines then the version of the function above.
> + */
> +static noinline_for_stack
> +char *put_dec(char *buf, unsigned long long n)
> +{
> +	uint32_t d3, d2, d1, q;
> +
> +	if (!n) {
> +		*buf++ = '0';
> +		return buf;
> +	}
> +
> +	d1  = (n >> 16) & 0xFFFF;
> +	d2  = (n >> 32) & 0xFFFF;
> +	d3  = (n >> 48) & 0xFFFF;

Are you assuming that sizeof(long long) == 8, always?

-- 
vda

  parent reply	other threads:[~2010-08-06  5:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-05 22:38 [PATCH 1/3] lib: vsprintf: optimised put_dec_trunc() and put_dec_full() Michal Nazarewicz
2010-08-05 22:38 ` [PATCH 2/3] lib: vsprintf: optimised put_dec() for 32-bit machines Michal Nazarewicz
2010-08-05 22:38   ` [PATCH 3/3] lib: vsprintf: added a put_dec() test and benchmark tool Michal Nazarewicz
2010-08-06  5:10     ` Denys Vlasenko
2010-08-06  8:34       ` Michał Nazarewicz
2010-08-06 15:57         ` Raja R Harinath
2010-08-06 19:26         ` Denys Vlasenko
2010-08-06 20:58           ` Michal Nazarewicz
2010-08-06  5:18   ` Denys Vlasenko [this message]
2010-08-06  7:08     ` [PATCH 2/3] lib: vsprintf: optimised put_dec() for 32-bit machines Michal Nazarewicz
2010-08-06  7:35       ` Denys Vlasenko
2010-08-06  8:54         ` Michał Nazarewicz
2010-08-06  3:58 ` [PATCH 1/3] lib: vsprintf: optimised put_dec_trunc() and put_dec_full() Denys Vlasenko
2010-08-06  6:56   ` Michal Nazarewicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201008060718.38345.vda.linux@googlemail.com \
    --to=vda.linux@googlemail.com \
    --cc=akpm@linux-foundation.org \
    --cc=jones@cs.uiowa.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.nazarewicz@samsung.com \
    --cc=mina86@mina86.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox