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]

Can a function return from the middle?


Can the compiled version of a C or C++ function ever return
from the middle, or must it always branch to a return sequence
at the end of the function?

For example, consider the function

   static int bar;
   int foo()
   {
      if ( bar )
         return 1;
      return 0;
   }

and the hypothetical assembler output:

    globl foo:
        tst (bar)
        bz  L1
        move #1,d0
        ret			; return from the middle
    L1: clr  d0
        ret


My question is whether gcc would actually output anything like this,
for any processor or at any level of optimization.

If the answer for gcc is NO, can one safely say the answer is NO
for any compiler?

If the answer for gcc is YES, can one safely say that gcc would never
do this for unoptimized code?

Thanks in advance

Russ Browne
Applied MicroSystems


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