Re: [PATCH 1/2] lzma support: decompression lib, initrd support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Andrew Morton wrote:
Christian Leber <[email protected]> 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)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux