[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] gcc-code-generation



Hi,

I am a little bit confused about code-generation of gcc 2.95.3.

I have this as input:

-----------------------
void f( short *x )
{
  long e;

  if( (unsigned long)&e & 1L )
  {
    *x = 3;
  }
  else
    *x = 5;
}

-----------------------


With -O0 I get:


-----------------------

#NO_APP
gcc2_compiled.:
___gnu_compiled_c:
.text
  .even
.globl _f
_f:
  link.w a6,#-4
  move.l a6,d0
  subq.l #4,d0
  moveq.l #1,d1
  and.l d0,d1
  tst.l d1
  jbeq L3
  move.l 8(a6),a0
  move.w #3,(a0)
  jbra L4
  .even
L3:
  move.l 8(a6),a0
  move.w #5,(a0)
L4:
L2:
  unlk a6
  rts

-----------------------


and with -O2 (or -O1):


-----------------------

#NO_APP
gcc2_compiled.:
___gnu_compiled_c:
.text
  .even
.globl _f
_f:
  link.w a6,#-4
  move.l 8(a6),a0
  move.w #5,(a0)
  unlk a6
  rts

-----------------------


so no test on the LSB is performed if optimization is on. That means the compiler thinks to know that the stack is word-aligned. Is this the same with gcc4?

--
Helmut Karlowski