[Bug inline-asm/97708] New: Inline asm does not use the local register asm specified with register ... asm() as input

bp at alien8 dot de gcc-bugzilla@gcc.gnu.org
Tue Nov 3 19:58:50 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97708

            Bug ID: 97708
           Summary: Inline asm does not use the local register asm
                    specified with register ... asm() as input
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: inline-asm
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bp at alien8 dot de
  Target Milestone: ---

Building the below on x86-64 with gcc9, gcc10 and Segher built with gcc11
20201015:

---
int main(void)
{

        register float foo asm ("xmm0") = 0.99f;

        asm volatile("movl %0, %%r8d\n\t"
                      "vmcall\n\t"
                      :: "g" (foo));

        return 0;
}
---

results in gcc not using the xmm0 register directly as the input register to
the asm statement but does something funky:

0000000000001125 <main>:
    1125:       55                      push   %rbp
    1126:       48 89 e5                mov    %rsp,%rbp
    1129:       f3 0f 10 05 d3 0e 00    movss  0xed3(%rip),%xmm0        # 2004
<_IO_stdin_used+0x4>
    1130:       00 
    1131:       66 0f 7e c0             movd   %xmm0,%eax
    1135:       41 89 c0                mov    %eax,%r8d
    1138:       0f 01 c1                vmcall 

by loading through the %eax GPR and producing wrong code without even a
warning. I'm not saying this example is supposed to make sense but this should
fail instead by trying to compile:

$ cat xmm1.s
        movl %xmm0,%eax

$ x86_64-linux-as xmm1.s -o xmm1.o
xmm1.s: Assembler messages:
xmm1.s:1: Error: unsupported instruction `mov'

and fail the build because plain MOV cannot use an XMM reg as a source.

Thx.


More information about the Gcc-bugs mailing list