This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Can a function return from the middle?
- To: gcc at gcc dot gnu dot org
- Subject: Can a function return from the middle?
- From: russ at amc dot com (Russell Browne)
- Date: Mon, 9 Apr 2001 14:21:21 -0700
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