[Issue 7181] Make bswap a recognized sequence, rather than an intrinsic
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Dec 29 09:29:50 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7181
--- Comment #2 from Don <clugdbug at yahoo.com.au> 2011-12-29 09:29:47 PST ---
(In reply to comment #1)
> (In reply to comment #0)
> > In the same way that abs, rol and ror are recognized, bswap(int x)
> > could be identified from:
> >
> > ( x << 24 ) | ( x << 8 ) & 0xff0000 | ( x >> 8 ) & 0xff00 | ( x >> 24 );
> >
> > and this would be completely portable.
>
> Even if this pattern gets recognized and optimized, I suggest to keep a bswap
> function in Phobos, to avoid writing all that bug-prone stuff (I'd like a
> rol/ror function pair too in Phobos).
Definitely. It would just change from:
int bswap(int); /* intrinsic */
into
int bswap(int x)
{
return ( x << 24 ) | ( x << 8 ) & 0xff0000 | ( x >> 8 ) & 0xff00 | ( x >>
24 );
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list