Thread overview
[dmd-internals] Code motion across volatile{Load, Store}
Jul 11, 2015
David Nadlinger
Aug 10, 2015
Martin Nowak
Aug 10, 2015
David Nadlinger
July 11, 2015
Hi all,

I've wanted to make the core.atomic implementation for DMD suck less for a long time now. One of its main problems is that DMD cannot inline the functions even when no barrier is required. On x86, barriers are only needed for sequentially consistent stores. All other loads and stores can be implemented as simple movs (not talking about rmw operations here).

With 2.067 the volatileLoad and volatileStore intrinsics were added, which are directly lowered to loads and stores. Is DMD's optimizer overly conservative here and prohibits *all* code motion across these (we only require them not to be reordered with atomic ops)? If so, this would be a good thing for once, as I could then efficiently implement the no-barrier case using them.

LDC of course just lowers the atomic ops to their LLVM IR counterparts.

Best,
David




_______________________________________________
dmd-internals mailing list
dmd-internals@puremagic.com
http://lists.puremagic.com/mailman/listinfo/dmd-internals
August 10, 2015
On 07/11/2015 08:27 PM, David Nadlinger via dmd-internals wrote:
> With 2.067 the volatileLoad and volatileStore intrinsics were added, which are directly lowered to loads and stores. Is DMD's optimizer overly conservative here and prohibits *all* code motion across these (we only require them not to be reordered with atomic ops)? If so, this would be a good thing for once, as I could then efficiently implement the no-barrier case using them.

No unnecessary hacks please, let's simply add intrinsics to dmd. https://issues.dlang.org/show_bug.cgi?id=13713




August 10, 2015
On 10 Aug 2015, at 11:37, Martin Nowak via dmd-internals wrote:
> On 07/11/2015 08:27 PM, David Nadlinger via dmd-internals wrote:
>> With 2.067 the volatileLoad and volatileStore intrinsics were added, which are directly lowered to loads and stores. Is DMD's optimizer overly conservative here and prohibits *all* code motion across these […]
>
> No unnecessary hacks please, let's simply add intrinsics to dmd.
> https://issues.dlang.org/show_bug.cgi?id=13713

Sure, this would be a much better solution. However, I have little inclination of digging into the DMD backend to add this myself. And given that Walter and Andrei still do not seem to acknowledge the importance of a well-defined and reasonably fine-grained memory model for today's high performance code, I am not holding my breath for somebody else to do it. (Ab)using volatile{Load, Store} would have simple been a quick fix for the currently abysmal DMD codegen on x86.

 — David
_______________________________________________
dmd-internals mailing list
dmd-internals@puremagic.com
http://lists.puremagic.com/mailman/listinfo/dmd-internals