* [parisc-linux] Re: [parisc-linux-cvs] Re: 2.6.0-test4-pa12 __fls()
[not found] <3F5A4023.9070909@tiscali.be>
@ 2003-09-06 22:33 ` Joel Soete
2003-09-07 6:11 ` Randolph Chung
0 siblings, 1 reply; 2+ messages in thread
From: Joel Soete @ 2003-09-06 22:33 UTC (permalink / raw)
To: Grant Grundler, Matthew Wilcox, parisc-linux
Hi Willy And Grant,
> On Fri, Sep 05, 2003 at 11:59:14PM -0600, Grant Grundler wrote:
> >/ > kudos to Joel Soete for mangling lamont's __ffs() to produce __fls().
/> >/ > Again, I added 64-bit support. Booted on a500.
/> >/ > Didn't test 32-bit but fls_test.c included in above URL works in user space.
/> >/ > (162 cycles per loop iteration, 00:29:01 to complete on 400Mhz PA8500).
/>
> Sorry, but it's clearly broken.
>
> >/ -#define fls(x) generic_fls(x)
/> >/ +static __inline__ unsigned long __fls(unsigned long x)
/> >/ +{
/> >/ + unsigned long ret;
/> >/ +
/> >/ + __asm__( " ldi 1,%1\n"
/> >/ +#if BITS_PER_LONG > 32
/> >/ + " extrd,u,*<> %0,63,32,%%r0\n"
/>
> if any of the bottom 32 bits are set ...
>
> >/ + " depd,*TR %0,31,32,%0\n"
/>
> move the bottom 32 bits up into the top 32 bits
>
> >/ + " addi 32,%1,%1\n"
/>
> otherwise add 32
>
> >/ +#endif
/>
> ... and then do things that can't see the top 32 bits.
hmm either I had to re-think the algo as you mentioned below
(so that to minimise the difference between 32 and 64 bits kernel)
or writing two distinct routine. (the 64 bits using depd,Z,*TR [...]
in place of 32 bits zdep
btw: is somebody knows how to compile with _hppa64-gcc_ shuch trivial loop
#include <stdio.h>
main()
{
unsigned long long i;
for (i=0; i<0xffffffffffffffffUL; i++) {
printf ("i = %#010x (%ll)\n", i);
}
}
(afair the problem if the call to printf() )
>
> >/ + " extru,<> %0,15,16,%%r0\n"
/> >/ + " zdep,TR %0,15,16,%0\n"
/> >/ + " addi 16,%1,%1\n"
/>
> think you could put in comments similar to the endian swapping? it makes
> the intent clearer to see.
My bad (in fact i was waiting some accept/reject comments before adding comment as pseudo_fls() was written)
> as far as i can tell, the basic principle
> here is..
>
> if (top N bits clear)
> shift N bits right
> else
> add N
>
> right?
Sorry, I trusted that pseudo_fls() in the mentionned message:
(http://lists.parisc-linux.org/pipermail/parisc-linux/2003-August/020628.html)
was enough ;)
>
> seems to me this whole thing should be done as
>
> if (any top N bits set)
> shift N bits left
> else
> subtract N
>
> >/ + " extru,<> %0,7,8,%%r19\n"
/>
> r19? That's not mentioned as being clobbered. I think you mean r0.
Yes a typo of mine (my bad sorry)
As i am in holidays, the pb is that I have no palinux box at my disposal to experiment another solution :(
Joel
PS: may i submit you an additional thought without any interest (may be):
the suggested code is "
+ return x ? (__ffs((unsigned long)x) + 1) : 0;
and if I refer to k&r book long is of 32bits lenght? (otc int is arch dependent)
But may be outdated by C99?
Thanks for additonal advise (and sorry for so much questions against so poor answers ;)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [parisc-linux] Re: [parisc-linux-cvs] Re: 2.6.0-test4-pa12 __fls()
2003-09-06 22:33 ` [parisc-linux] Re: [parisc-linux-cvs] Re: 2.6.0-test4-pa12 __fls() Joel Soete
@ 2003-09-07 6:11 ` Randolph Chung
0 siblings, 0 replies; 2+ messages in thread
From: Randolph Chung @ 2003-09-07 6:11 UTC (permalink / raw)
To: Joel Soete; +Cc: parisc-linux
> btw: is somebody knows how to compile with _hppa64-gcc_ shuch trivial loop
> #include <stdio.h>
>
> main()
> {
> unsigned long long i;
>
> for (i=0; i<0xffffffffffffffffUL; i++) {
> printf ("i = %#010x (%ll)\n", i);
> }
> }
>
> (afair the problem if the call to printf() )
we don't have 64-bit glibc/userspace yet, so you can't do this.
randolph
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-09-07 6:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <3F5A4023.9070909@tiscali.be>
2003-09-06 22:33 ` [parisc-linux] Re: [parisc-linux-cvs] Re: 2.6.0-test4-pa12 __fls() Joel Soete
2003-09-07 6:11 ` Randolph Chung
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox