This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Gcc extra alignment..
Graham Stott wrote:
>
> Richard Henderson wrote:
> >
> > On Wed, Nov 01, 2000 at 09:55:31AM +0100, Christian Iseli wrote:
> > > I'm afraid things are not quite that simple. I'm pretty sure people used
> > > the break statement to get out early of those phony loops.
> >
> > Sigh, yes indeed. This one actually survived a bootstrap.
> >
> OK we now handle break statements but what about continue statements. I don't think
> this code will work for a do { ....} while (0) with a continue statement.
>
> Graham
Here's a patch bootstrapped on x86 and also successfully compiled the following
simple test case.
------------------------------------------------------------------------------
extern int break_cond(void);
extern int cont_cond(void);
void dummy()
{
do
{
if (cont_cond())
continue;
if (break_cond())
break;
} while (0);
}
------------------------------------------------------------------------------
ChangeLog
* stmt.c (expand_start_null_loop): Generate and emit a label for
use by possible continue statement.
-----------------------------------------------------------------------------------
Index: stmt.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/stmt.c,v
retrieving revision 1.172
diff -c -p -r1.172 stmt.c
*** stmt.c 2000/11/01 10:28:32 1.172
--- stmt.c 2000/11/01 12:40:09
*************** expand_start_null_loop ()
*** 2307,2320 ****
thisloop->next = loop_stack;
thisloop->all = nesting_stack;
thisloop->depth = ++nesting_depth;
! thisloop->data.loop.start_label = emit_note (NULL, NOTE_INSN_DELETED);
thisloop->data.loop.end_label = gen_label_rtx ();
thisloop->data.loop.alt_end_label = NULL_RTX;
! thisloop->data.loop.continue_label = NULL_RTX;
thisloop->exit_label = thisloop->data.loop.end_label;
loop_stack = thisloop;
nesting_stack = thisloop;
return thisloop;
}
--- 2307,2323 ----
thisloop->next = loop_stack;
thisloop->all = nesting_stack;
thisloop->depth = ++nesting_depth;
! thisloop->data.loop.start_label = gen_label_rtx ();
thisloop->data.loop.end_label = gen_label_rtx ();
thisloop->data.loop.alt_end_label = NULL_RTX;
! thisloop->data.loop.continue_label = thisloop->data.loop.start_label;
thisloop->exit_label = thisloop->data.loop.end_label;
loop_stack = thisloop;
nesting_stack = thisloop;
+ do_pending_stack_adjust();
+ emit_queue ();
+ emit_label(thisloop->data.loop.continue_label);
return thisloop;
}
------------------------------------------------------------------------------------
Graham