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/docs/LangRef.html#llvm-fshl-intrinsic
It's a fairly new intrinsic, so won't work with older LLVM
versions.
https://d.godbolt.org/z/SBnJFJ
As noted by others, the optimizer is strong enough to recognize
what you are doing (without intrinsic) and use ror/rol if it
deems it advantageous to do so.
-Johan