Re: Bits rotations

2012-10-18 Thread Iain Buclaw
On 18 October 2012 03:36, bearophile bearophileh...@lycos.com wrote: In cryptographic code, and generally in bit-twiddling code, rotation of the bits in a word is a common operation. It's so common that Intel has made it an asm instruction. A demo program: uint foo(in uint x) pure nothrow

Re: Bits rotations

2012-10-18 Thread Iain Buclaw
On 18 October 2012 09:27, bearophile bearophileh...@lycos.com wrote: Iain Buclaw: In the gdc-4.6 package you have there, it's only naked asm that can't be inlined. Good. However it is worth noting that DIASM is no longer in mainline gdc. What's DIASM? Is it the D syntax for asm

Re: Bits rotations

2012-10-18 Thread Don Clugston
On 18/10/12 11:39, Iain Buclaw wrote: On 18 October 2012 09:27, bearophile bearophileh...@lycos.com wrote: Iain Buclaw: In the gdc-4.6 package you have there, it's only naked asm that can't be inlined. Good. However it is worth noting that DIASM is no longer in mainline gdc. What's

Re: Bits rotations

2012-10-18 Thread Iain Buclaw
On 18 October 2012 15:22, Don Clugston d...@nospam.com wrote: On 18/10/12 11:39, Iain Buclaw wrote: On 18 October 2012 09:27, bearophile bearophileh...@lycos.com wrote: Iain Buclaw: In the gdc-4.6 package you have there, it's only naked asm that can't be inlined. Good. However it

Re: Bits rotations

2012-10-17 Thread Adam D. Ruppe
On Thursday, 18 October 2012 at 02:36:59 UTC, bearophile wrote: uint foo(in uint x) pure nothrow { return (x 11) | (x (32 - 11)); } Why would you write that instead of using rol(x, 11) today? uint rol(in uint x, in uint y) pure nothrow { return (x y) | (x (32 - y)); } uint foo(in

Re: Bits rotations

2012-10-17 Thread H. S. Teoh
On Thu, Oct 18, 2012 at 04:55:38AM +0200, Adam D. Ruppe wrote: On Thursday, 18 October 2012 at 02:36:59 UTC, bearophile wrote: uint foo(in uint x) pure nothrow { return (x 11) | (x (32 - 11)); } Why would you write that instead of using rol(x, 11) today? uint rol(in uint x, in uint