Re: Bitwise rotate of integral

2019-01-08 Thread Reimer Behrends via Digitalmars-d-learn
On Tuesday, 8 January 2019 at 09:15:09 UTC, Patrick Schluter wrote: 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). Looking at the dmd compiler source code, it requires the value to be rotated to

Re: Bitwise rotate of integral

2019-01-08 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 8 January 2019 at 12:35:16 UTC, H. S. Teoh wrote: On Tue, Jan 08, 2019 at 09:15:09AM +, Patrick Schluter via Digitalmars-d-learn wrote: On Monday, 7 January 2019 at 23:20:57 UTC, H. S. Teoh wrote: [...] > [...] Are you sure it's dmd looking for the pattern. Playing with the

Re: Bitwise rotate of integral

2019-01-08 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 08, 2019 at 09:15:09AM +, Patrick Schluter via Digitalmars-d-learn wrote: > On Monday, 7 January 2019 at 23:20:57 UTC, H. S. Teoh wrote: [...] > > There's a certain pattern that dmd looks for, that it transforms > > into a ROL instruction. Similarly for ROR. Deviate too far from

Re: Bitwise rotate of integral

2019-01-08 Thread Johan Engelen via Digitalmars-d-learn
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? LDC does not expose this intrinsic currently, but you can use LLVM's fshl: https://llvm.org

Re: Bitwise rotate of integral

2019-01-08 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 7 January 2019 at 23:20:57 UTC, H. S. Teoh wrote: On Mon, Jan 07, 2019 at 11:13:37PM +, 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 valu

Re: Bitwise rotate of integral

2019-01-07 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jan 07, 2019 at 11:13:37PM +, 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 intr

Re: Bitwise rotate of integral

2019-01-07 Thread Guillaume Piolat via Digitalmars-d-learn
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.

Re: Bitwise rotate of integral

2019-01-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/7/19 10:10 AM, Per Nordlöw wrote: On Monday, 7 January 2019 at 14:53:26 UTC, Alex wrote: There are https://dlang.org/phobos/core_bitop.html#.rol and https://dlang.org/phobos/core_bitop.html#.ror But it seems the implementation is like yours. Ahh, missed that. Thanks. Use the

Re: Bitwise rotate of integral

2019-01-07 Thread Per Nordlöw via Digitalmars-d-learn
On Monday, 7 January 2019 at 14:53:26 UTC, Alex wrote: There are https://dlang.org/phobos/core_bitop.html#.rol and https://dlang.org/phobos/core_bitop.html#.ror But it seems the implementation is like yours. Ahh, missed that. Thanks.

Re: Bitwise rotate of integral

2019-01-07 Thread Alex via Digitalmars-d-learn
On Monday, 7 January 2019 at 14:43:29 UTC, Per Nordlöw 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? I just found this ulong

Re: Bitwise rotate of integral

2019-01-07 Thread Per Nordlöw via Digitalmars-d-learn
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? I just found this ulong rotateLeft(ulong x, ubyte bits) { return (x <<

Bitwise rotate of integral

2019-01-07 Thread Per Nordlöw via Digitalmars-d-learn
What's the preferred way of doing bitwise rotate of an integral value in D? Are there intrinsics for bitwise rotation available in LDC?