All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paulo Marques <pmarques@grupopie.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Christian Leber <christian@leber.de>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] lzma support: decompression lib, initrd support
Date: Tue, 14 Jun 2005 13:39:15 +0100	[thread overview]
Message-ID: <42AECFF3.7030604@grupopie.com> (raw)
In-Reply-To: <20050607145903.4b2ac9bf.akpm@osdl.org>

Andrew Morton wrote:
> Christian Leber <christian@leber.de> wrote:
> [...]
>>+	for (pb = 0; prop0 >= (9 * 5); pb++, prop0 -= (9 * 5));
>>+	for (lp = 0; prop0 >= 9; lp++, prop0 -= 9);
> 
> Put the ";" on a line of its own.
> 
> I'd have thought the above could be done arithmetically?

I just tried a small test program to see the speed/code size difference 
to this code, which is the arithmetic equivalent:

   pb = prop0 / (9 * 5);
   prop0 %= (9 * 5);
   lp = prop0 / 9;
   prop0 %= 9;

This code runs a lot faster than the original. This is not very 
important since it runs only once AFAICT.

As for the code size, it is smaller if compiled with -Os, but larger 
when compiled with -O2 or -O3.

When compiled with -Os, gcc uses the idiv instruction and it even uses 
its reminder so that it only does 2 idiv instructions to do the 4 
operations above.

With -O2 or -O3, it does a hard to follow division "by hand" using 
several instructions, rendering the code about 2.5x larger (but 
amazingly a lot faster).

The tests were done with gcc 3.3.2.

-- 
Paulo Marques - www.grupopie.com

An expert is a person who has made all the mistakes that can be
made in a very narrow field.
Niels Bohr (1885 - 1962)

  parent reply	other threads:[~2005-06-14 12:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-07 21:32 [PATCH 1/2] lzma support: decompression lib, initrd support Christian Leber
2005-06-07 21:59 ` Andrew Morton
2005-06-12 21:43   ` Christian Leber
2005-06-13 20:03     ` Jesper Juhl
2005-06-13 23:33       ` Christian Leber
2005-06-13 21:35     ` Roman Zippel
2005-06-14 12:39   ` Paulo Marques [this message]
2005-06-14 12:54     ` Christian Leber

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=42AECFF3.7030604@grupopie.com \
    --to=pmarques@grupopie.com \
    --cc=akpm@osdl.org \
    --cc=christian@leber.de \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.