https://sourceware.org/bugzilla/show_bug.cgi?id=32462

--- Comment #2 from Michael Clark <michaeljclark at mac dot com> ---
someone on LLVM discourse said on Intel, f3 90 is pause,
independent of REX.B. On AMD, it is pause only if REX.B
is clear. the behavior of rep xchg is unspecified.

so it seems that QEMU code snippet is consistent with AMD.

possibly should have a (bad) in there as while it clashes
with the PAUSE alias, it is logically 'rep xchg eax, r8d'.

I compiled this with clang because it accepts 'rep xchg'

---

#include <stdio.h>

long xchgl(long a, long b)
{
    __asm__ __volatile__ (
        "movq %1, %%rax \n"
        "movq %2, %%r8 \n"
        "xchgl %%eax, %%r8d \n"
        "movq %%rax, %1 \n"
        "movq %%r8, %2 \n"
        : "+r"(a), "+r"(b)
        :
        : "rax", "r8");
    return a;
}
long repxchgl(long a, long b)
{
   __asm__ __volatile__ (
        "movq %1, %%rax \n"
        "movq %2, %%r8 \n"
        "rep xchgl %%eax, %%r8d \n"
        "movq %%rax, %1 \n"
        "movq %%r8, %2 \n"
        : "+r"(a), "+r"(b)
        :
        : "rax", "r8");
    return a;
}

int main()
{
    printf("%ld\n",xchgl(3,6));
    printf("%ld\n",repxchgl(3,6));
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to