[Issue 21041] core.bitop.byteswap(ushort) should used ROL/ROR instead of XCHG

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jul 12 15:39:45 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=21041

--- Comment #5 from Bruce Carneal <bcarneal11 at gmail.com> ---
(In reply to safety0ff.bugz from comment #3)
> (In reply to Bruce Carneal from comment #1)
> > Current dmd -O emits 7 instructions to accomplish the rolw in the code body.
> 
> D converts many operations on narrow types to int, which DMD's backend then
> fails to optimize away when it is possible/advantageous.

Yes.  DMDs back end is quick, but the code it generates is not
state-of-the-art.

That said, optimizing the DMD code gen for code.bitop rotations seems more
useful than a ushort byteswap improvement.  The latter could be implemented as
an "inline" of the former.

Recognizing the rotation patterns generally, ala LLVM, would be even better but
quite a bit of work I'd imagine.  Probably not worth it given current resource
constraints (Walter's time).  Lots of big front-end fish to fry.

--


More information about the Digitalmars-d-bugs mailing list