This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Bad sparc64 code when returning structure with leading float



Hello all,

We have a serious problem (bogus assembly code generation) with the following
configuration :

o gcc version 2.97 20010102 (experimental)

o sparc64-wrs-vxworks target,  hosted on sparc-sun-solaris2.5.1

o Configured with: 
  --with-gnu-as --disable-nls --prefix=... --target=sparc64-wrs-vxworks
  --enable-languages=c,ada

This is a cross compiler, but I think the problem (detailed below) might occur
with other sparc64 configurations.  

I suspect this comes from the function_arg_return_value() family of functions.


Thanks in advance for any help you can provide,

Kind Regards,

Olivier


--

From the following C code :

/* db.c */

typedef struct {
  float f;
  int   i;
  int   j;
} datablock_t;

datablock_t datablock (void);

datablock_t datablock (void)
{
  datablock_t db;

  /* f not initialized to avoid extra assembly
   * instructions in the report below.
   */
  db.i = 11;
  db.j = 22;

  return db;  
}

We get assembly code for the datablock function that simply "forgets" the j field in
the return value :

$ sparc64-wrs-vxworks-gcc -S db.c

     1          .file   "db.c"
     2  gcc2_compiled.:
     3          .section        ".text"
     4          .align 4
     5          .global datablock
     6          .type   datablock,#function
     7          .proc   010
     8  datablock:
     9          !#PROLOGUE# 0
    10          save    %sp, -224, %sp
    11          !#PROLOGUE# 1
    12          mov     11, %g2
    13          st      %g2, [%fp-28]
    14          mov     22, %g2
    15          st      %g2, [%fp-24]
    16          ld      [%fp-32], %f0
    17          ld      [%fp-28], %i0
    18          return  %i7+8
    19          nop
    20  .LLfe1:
    21          .size   datablock,.LLfe1-datablock
    22          .ident  "GCC: (GNU) 2.97 20010102 (experimental)"


This is yet more obvious with optimization on (O2) :

     1          .file   "db.c"
     2  gcc2_compiled.:
     3          .section        ".text"
     4          .align 4
     5          .global datablock
     6          .type   datablock,#function
     7          .proc   010
     8  datablock:
     9          !#PROLOGUE# 0
    10          add     %sp, -224, %sp
    11          !#PROLOGUE# 1
    12          mov     11, %o0
    13          ld      [%sp+192], %f0
    14          retl
    15          sub     %sp, -224, %sp
    16  .LLfe1:
    17          .size   datablock,.LLfe1-datablock
    18          .ident  "GCC: (GNU) 2.97 20010102 (experimental)"



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]