Bitwise rotate of integral

Patrick Schluter Patrick.Schluter at bbox.fr
Tue Jan 8 09:15:09 UTC 2019


On Monday, 7 January 2019 at 23:20:57 UTC, H. S. Teoh wrote:
> On Mon, Jan 07, 2019 at 11:13:37PM +0000, Guillaume Piolat via 
> Digitalmars-d-learn wrote:
>> On Monday, 7 January 2019 at 14:39:07 UTC, Per Nordlöw wrote:
>> > What's the preferred way of doing bitwise rotate of an 
>> > integral value in D?
>> > 
>> > Are there intrinsics for bitwise rotation available in LDC?
>> 
>> Turns out you don't need any:
>> 
>> https://d.godbolt.org/z/C_Sk_-
>> 
>> Generates ROL instruction.
>
> There's a certain pattern that dmd looks for, that it 
> transforms into a ROL instruction. Similarly for ROR.  Deviate 
> too far from this pattern, though, and it might not recognize 
> it as it should.  To be sure, always check the disassembly.
>
Are you sure it's dmd looking for the pattern. Playing with the 
godbolt link shows that dmd doesn't generate the rol code (gdc 
4.8.2 neither).



More information about the Digitalmars-d-learn mailing list