[Bug inline-asm/56479] New: Register allocator can't allocate two 4-byte variables into 8 registers for inline asm on avr-gcc

Shulyaka at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Feb 28 07:51:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56479

             Bug #: 56479
           Summary: Register allocator can't allocate two 4-byte variables
                    into 8 registers for inline asm on avr-gcc
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: inline-asm
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: Shulyaka@gmail.com


Hi!

When I try to compile the following code with avr-gcc for atmega2560 cpu:

------------------------------------------------
#include <stdint.h>

uint64_t asmfoo(uint32_t x, uint32_t y);

int main(void)
{ return (int)asmfoo(1234, 5678); }

uint64_t asmfoo(uint32_t x, uint32_t y)
{
  uint64_t z;
  asm volatile (
  "nop \n\t" //I'm going to make use of fmul instructions here
  "nop \n\t" //which only accept r16-r23 registers
  "nop \n\t"
  : [Z]"=&r"(z)           //"r" is any general register (r1-r32)
  : [X]"a"(x), [Y]"a"(y)  //"a" is a simple upper register (r16-r23)
  );
  return z;
}
-------------------------------------------------

I get the following error:

$ avr-gcc-4.7.2 -c test.c
test.c: In function 'asmfoo':
test.c:13: error: can't find a register in class 'SIMPLE_LD_REGS' while
reloading 'asm'
test.c:13: error: 'asm' operand has impossible constraints

I have tested it with 4.3.2 and 4.7.2 with different optimization levels.

On the other hand, the following code DOES compile:

-------------------------------------------------
#include <stdint.h>

uint64_t asmfoo(uint64_t x, uint32_t y);

int main(void)
{ return (int)asmfoo(1234, 5678); }

uint64_t asmfoo(uint64_t x, uint32_t y)  //       <-note the uint64_t
{
  uint64_t z;
  asm volatile (
  "nop \n\t"
  "nop \n\t"
  "nop \n\t"
  : [Z]"=&r"(z)
  : [X]"a"(x)          //                     <-note the absence of y
  );
  return z;
}
-------------------------------------------------



More information about the Gcc-bugs mailing list