https://issues.dlang.org/show_bug.cgi?id=21041
Bruce Carneal <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #1 from Bruce Carneal <[email protected]> --- I didn't find a 'byteswap' in the core.bitop documentation. There is a bswap but only for uints and ulongs AFAICT. Regardless, here's a byteswap implementation for discussion: auto byteswap(ushort x) { return cast(ushort)(x >> 8 | x << 8); } For the above code ldc at -O or above generates: movl %edi, %eax rolw $8, %ax retq With ldc you can also get the above sequence using core.bitop.rol!8 explicitly. Current dmd -O emits 7 instructions to accomplish the rolw in the code body. The code emitted by dmd -O for the explicit call to core.bitop.rol is even worse, which is strange. So, yes, there's room here for DMD code gen improvement but ldc is right there. --
