This is the mail archive of the gcc@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]

How to generate "cmpl %eax,%eax ; jne" with -O9, gcc-2-95.2


  Hello,

  Just to log this small problem, if someone
 want to spend time on it.

  I was trying to detect if a function had some local
 variables in the stack, not only in register - and if
 so call an __ERROR() function that the linker would
 refuse to link, because then I know that my function
 will not work.

  Here is the equivalent file:
----------------------
int fct (void)
  {
  if (*(void **)__builtin_frame_address(0) != __builtin_return_address(0))
      return 1;
    else
      return 0;
  }
----------------------
  And if compiled with:
gcc -O9 -fomit-frame-pointer -mpreferred-stack-boundary=2 -S testgcc.c -o -
  I get with gcc-2.95.2:
----------------------
        .file   "testgcc.c"
        .version        "01.01"
gcc2_compiled.:
.text
        .align 4
.globl fct
        .type    fct,@function
fct:
        movl (%esp),%eax	#
        cmpl %eax,%eax		# would be nice to optimise....
        jne .L3			#
        xorl %eax,%eax
        ret
        .p2align 4,,7
.L3:
        movl $1,%eax
        ret
.Lfe1:
        .size    fct,.Lfe1-fct
        .ident  "GCC: (GNU) 2.95.2 19991024/Linux (release)"
----------------------


  Have a nice day,
  Etienne.

___________________________________________________________
Do You Yahoo!?
Achetez, vendez! À votre prix! Sur http://encheres.yahoo.fr

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