GDC optimizations bug ?
Iain Buclaw via D.gnu
d.gnu at puremagic.com
Sun Nov 9 00:54:04 PST 2014
On 9 Nov 2014 08:40, "Maor via D.gnu" <d.gnu at puremagic.com> wrote:
>
> Hi,
>
> I'm trying to compile a program using inline asm with optimizations and I
got my inline asm functions thrown out by the optimizer although I declared
them as having side effects (by stating a memory clobber).
> I wrote the following toy program to demonstrate the problem:
>
> ----------------------------------------------
>
> import std.stdio;
> import gcc.attribute;
>
> @attribute("forceinline") ulong exchangeAndAdd(shared ulong *counter,
ulong addition) {
> ulong retVal = void; // we don't want it initialized when dmd is
used
> asm {
> "
> mov %2, %0 ;
> lock ;
> xadd %0, (%1) ;
> ":
> "=&r"(retVal) :
> "r"(counter), "r"(addition) :
Maybe try: "=m"(*counter)
The bug is likely in your input/output clobbers, gcc will always optimise
against you unless you get the input/output/clobbers precisely correct.
Iain.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/d.gnu/attachments/20141109/c23087ee/attachment.html>
More information about the D.gnu
mailing list