[Issue 20131] New: Bad codegen from inline asm; possible REX prefix missing

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Aug 15 07:40:55 UTC 2019


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

          Issue ID: 20131
           Summary: Bad codegen from inline asm; possible REX prefix
                    missing
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: turkeyman at gmail.com

Compile and dump using:

> dmd asmtest.d -O -c -m64 && objdump asmtest.o -S

asmtest.d
---------
    bool cas(byte*, byte*, byte)
    {
        asm pure nothrow @nogc @trusted
        {
            naked;
            mov AL, [RSI];
            lock; cmpxchg [RDX], DIL;
            mov DL, AL;
            setz AL;
            je skip_writeback;
            mov [RSI], DL;
        skip_writeback:
            ret;
        }
    }

Emits:

Disassembly of section .text._D7asmtest3casFPgQcgZb:

0000000000000000 <_D7asmtest3casFPgQcgZb>:
   0:   8a 06                   mov    (%rsi),%al
   2:   f0 0f b0 3a             lock cmpxchg %bh,(%rdx)
   6:   88 c2                   mov    %al,%dl
   8:   0f 94 c0                sete   %al
   b:   74 02                   je     f <_D7asmtest3casFPgQcgZb+0xf>
   d:   88 16                   mov    %dl,(%rsi)
   f:   c3                      retq

Note:
Src: lock; cmpxchg [RDX], DIL;
Output: lock cmpxchg %bh,(%rdx)

DIL turned into %bh. only 4 bytes including LOCK... REX prefix missing maybe?

Blocks https://github.com/dlang/druntime/pull/2735

--


More information about the Digitalmars-d-bugs mailing list