On Dec 7, 09 05:02, Don wrote:
bearophile wrote:
Don:

I think DMD should just do what gcc does: recognize that
(x << 32-n | x>>n) is ror n
(x << n | x>> 32-n) is rol n
where x is int. Ugly, but doesn't require an intrinsic.

Thanks, but no thanks, it's too much ugly and it gets even more ugly
if you need to use that with ulongs or ushorts, etc. It seems Walter
doesn't want to remove the unsigned shift, so for the rotations it's
much better to add a rol/ror to std.intrinsic (plus something to read
the carry bit, etc).

Bye,
bearophile

The problem is, std.intrinsic is scarcely more portable than inline asm.
It doesn't even work on LDC!
You then get problems with user defined types that want to have a rotate.
BTW, if the above intrinsic existed, you would just define:

T ror(T)(T x, uint n)
{
return (x << ((T.sizeof*8)-n) | x>>n);
}

Shouldn't that be a problem of ldc, the implementation of std.intrinsic, or both? The interface of std.intrinsic is perfectly fine.

Reply via email to