This is the mail archive of the gcc-help@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]
Other format: [Raw text]

Generating wrong code for passing structure variable to a function (block_move_via_loop)


Hi all,

We have ported gcc-3.3 (cross compiler) for our custom processor.
To verify the port we have executed gcc.c-torture cases at different optimization levels.But following testcase was failed at -Os optimization.
gcc-3.3/gcc/testsuite/gcc.c-torture/execute/921117-1.c


To pass a structure variable "cell" to check(), our cross compiler generating following type of dumb code:
(for simple representation I have written it in pseudo code)


count = 1;
ptr =(char *) &cell
var = (char) *ptr;
label:
compare 'count' with 0x10 /* infinite loop */
bltu label;
*(stack) = var;


Instead of

count = 1;
ptr = (char *)&cell;
label:
count++;
var = (char) *ptr;
*(stack) = var;
stack++;
ptr++; compare 'count' with 0x10
bltu label;


I am unable to find what may be the actual reason, It was happened only at -Os optimization level.
Can you please help me in this regard.


Thanks,
Siva Prasad


For reference, I am sending the failed testcase: 921117-1.c


struct s {
 int flag;
 char text[10];
} cell;

int
check (struct s p)
{
 if (p.flag != 99)
   p.flag++;
   return 0;
  return strcmp (p.text, "0123456789");
}

main ()
{
 int k;
 check(cell);
  if(k)
   abort();
 exit (0);
}




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