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

--- Comment #1 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
Created attachment 41249
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41249&action=edit
loopasm.s: Generated assembly

Assembler output as generated with

$ avr-gcc loopasm.c -O2 -dp -S -std=gnu99

The source code issues two "syscalls" arranged in a loop:

static __inline__ __attribute__((__always_inline__))
void syscall_7 (int v1, int v2)
{
    register int r20 __asm ("20") = v1;
    register int r24 __asm ("24") = v2;
    __asm __volatile__ ("/* SYSCALL_7 %0 %1 */" :: "r" (r20), "r" (r24));
}

void do_syscalls (void)
{
    for (int s = 0; s < 2; s++)
    {
        syscall_7 (0, 8);
        syscall_7 (1, 9);
    }
}


The generated assembler misses some of the arguments; the asm reads:

do_syscalls:
        ldi r20,0        ;  5   *movhi/2        [length = 2]
        ldi r21,0
        ldi r24,lo8(8)   ;  6   *movhi/5        [length = 2]
        ldi r25,0
        /* SYSCALL_7 r20 r24 */
        ldi r20,lo8(1)   ;  8   *movhi/5        [length = 2]
        ldi r21,0
        ldi r24,lo8(9)   ;  9   *movhi/5        [length = 2]
        ldi r25,0
        /* SYSCALL_7 r20 r24 */
        /* SYSCALL_7 r20 r24 */
        /* SYSCALL_7 r20 r24 */
        ret      ;  18  return  [length = 1]

The 1st syscall_7 is expanded correctly: insns 5/6 load 0/8 to specified regs,
then follows SYSCALL_7.

The 2st syscall_7 is expanded correctly: insns 8/9 load 1/9 to specified regs,
then follows SYSCALL_7.

The 3rd and 4th syscall_7 are expanded incorrect: Inline asm SYSCALL_7 is
performed without setting the specified regs to their values.

== configure ==

Configured with: ../../gcc.gnu.org/gcc-6-branch/configure --target=avr
--prefix=/local/gnu/install/gcc-6-avr-mingw32 --host=i386-mingw32
--build=x86_64-linux-gnu --enable-languages=c,c++ --disable-nls
--disable-shared --enable-lto --with-dwarf2 --with-gnu-ld --with-gnu-as
Thread model: single
gcc version 6.3.1 20161222 [gcc-6-branch revision 243886] (GCC)

Reply via email to