This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Language-independent functions-as-trees representation
On Mon, Aug 26, 2002 at 10:56:21PM -0400, Diego Novillo wrote:
> *shrug* So, if the first node of a LOOP_EXPR_BODY is an
> EXIT_EXPR then I'm dealing with a while(), otherwise I'm dealing
> with a do/while? I guess it would work.
No. Consider
while (foo() == bar())
baz();
LOOP_EXPR
T.1 = foo();
T.2 = bar();
EXIT_EXPR T.1 != T.2;
baz();
vs
do {
baz();
} while (foo() == bar());
LOOP_EXPR
baz();
T.1 = foo();
T.2 = bar();
EXIT_EXPR T.1 != T.2;
Why does CFG creation care about the difference between while
and do/while anyway?
One thing I do note here is that loop rotation cannot be done
easily and correctly with things in this form. I fixed a bug
with that just this year. See
2002-01-30 Richard Henderson <rth@redhat.com>
PR opt/5076
* rtl.h (NOTE_INSN_LOOP_END_TOP_COND): New.
* rtl.c (note_insn_name): Update.
* emit-rtl.c (remove_unnecessary_notes): Kill it.
* stmt.c (expand_end_loop): Kill jump opt code. Use LOOP_END_TOP_COND
to perform loop rotation.
(expand_exit_loop_top_cond): New.
* tree.h (expand_exit_loop_top_cond): Declare it.
* c-semantics.c (genrtl_while_stmt): Use it.
(genrtl_for_stmt): Likewise.
I don't see that the problem encountered at the rtl level
will be any different at the tree level. This might be evidence
for retaining distinct WHILE and DO_WHILE nodes and dispensing
with plain LOOP_EXPR.
r~