From: "Joel Soete" <jsoe0708@tiscali.be>
To: parisc-linux@lists.parisc-linux.org
Subject: [parisc-linux] a fast fls also for 2.6?
Date: Thu, 7 Aug 2003 17:37:35 +0200 [thread overview]
Message-ID: <3F2E2C7700000FE5@ocpmta2.freegates.net> (raw)
Hi pa,
well as last 2.6 doesn't yet boot on my b2k and having any chance to grab
any debug info (I tried 32bits and 64bits kernel: same results. And only
TOC just refer to unrelevant info. OTC it seems to works fine on the b180.
I really don't know where to look for this bug?), I tried to understand better
Lamont's Fastffs code. To verify that I actualy understand it, I tried this
Fast_fls:
#include <stdio.h>
#include <limits.h>
int generic_fls(int x)
{
int r = 32;
if (!x)
return 0;
if (!(x & 0xffff0000u)) {
x <<= 16;
r -= 16;
}
if (!(x & 0xff000000u)) {
x <<= 8;
r -= 8;
}
if (!(x & 0xf0000000u)) {
x <<= 4;
r -= 4;
}
if (!(x & 0xc0000000u)) {
x <<= 2;
r -= 2;
}
if (!(x & 0x80000000u)) {
x <<= 1;
r -= 1;
}
return r;
}
int PseudoFast_fls(int x)
{
/*
Rewritte off generic_fls to mimic what would be done in asm
(just as proof of concept)
*/
int r = 1;
if (!x)
return 0;
if (!(x & 0xffff0000u))
x <<= 16;
else
r += 16;
if (!(x & 0xff000000u))
x <<= 8;
else
r += 8;
if (!(x & 0xf0000000u))
x <<= 4;
else
r += 4;
if (!(x & 0xc0000000u))
x <<= 2;
else
r += 2;
if (!(x & 0x80000000u))
x <<= 1;
else
r += 1;
return r;
}
int __fls(int x)
{
int ret;
__asm__(" ldi 1,%1\n"
" extru,<> %0,15,16,%%r0\n"
" zdep,TR %0,15,16,%0\n"
" addi 16,%1,%1\n"
" extru,<> %0,7,8,%%r19\n"
" zdep,TR %0,23,24,%0\n"
" addi 8,%1,%1\n"
" extru,<> %0,3,4,%%r19\n"
" zdep,TR %0,27,28,%0\n"
" addi 4,%1,%1\n"
" extru,<> %0,1,2,%%r19\n"
" zdep,TR %0,29,30,%0\n"
" addi 2,%1,%1\n"
" extru,= %0,0,1,%%r19\n"
" addi 1,%1,%1\n"
: "=r" (x), "=r" (ret)
: "0" (x), "1" (ret));
return ret;
}
int Fastfls(int x)
{
int ret;
if (!x)
return 0;
return (__fls(x));
}
main()
{
unsigned int i;
for (i=0; i<0xffffffffU; i++) {
/* if (generic_fls(i) != PseudoFast_fls(i)) */
if (generic_fls(i) != Fastfls(i))
printf ("Problem with i = %#010x (%d)\n", i, i);
}
}
Cheers,
Joel
PS: Don not hesitate to let me know if you would like that I make a patch
with this stuff
------------------------------------------------------
Soldes Tiscali ADSL : 27,50 euros/mois jusque fin 2003.
On s'habitue vite à payer son ADSL moins cher!
Plus d'info? Cliquez ici... http://reg.tiscali.be/default.asp?lg=fr
next reply other threads:[~2003-08-07 15:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-07 15:37 Joel Soete [this message]
[not found] <3F58838A.9010203@tiscali.be>
[not found] ` <3F5888F3.5060609@tiscali.be>
2003-09-05 18:26 ` [parisc-linux] a fast fls also for 2.6? Grant Grundler
2003-09-05 19:26 ` Joel Soete
2003-09-05 19:29 ` Grant Grundler
2003-09-05 19:54 ` Joel Soete
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=3F2E2C7700000FE5@ocpmta2.freegates.net \
--to=jsoe0708@tiscali.be \
--cc=parisc-linux@lists.parisc-linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox