Commit 8cadeff1 by Roger Sayle Committed by Roger Sayle

c-semantics.c (genrtl_while_stmt): Improve initial RTL generation when loop…

c-semantics.c (genrtl_while_stmt): Improve initial RTL generation when loop condition is known true, i.e.


	* c-semantics.c (genrtl_while_stmt):  Improve initial RTL generation
	when loop condition is known true, i.e.  "while (1) { ... }".
	(genrtl_for_stmt): Similarly for "for" statements.

From-SVN: r61338
parent 03cd8aba
2003-01-15 Roger Sayle <roger@eyesopen.com> 2003-01-15 Roger Sayle <roger@eyesopen.com>
* c-semantics.c (genrtl_while_stmt): Improve initial RTL generation
when loop condition is known true, i.e. "while (1) { ... }".
(genrtl_for_stmt): Similarly for "for" statements.
2003-01-15 Roger Sayle <roger@eyesopen.com>
* real.c (real_sqrt): Return a bool result indicating whether * real.c (real_sqrt): Return a bool result indicating whether
a floating point exception or trap should be raised. a floating point exception or trap should be raised.
* real.h (real_sqrt): Update function prototype. * real.h (real_sqrt): Update function prototype.
......
/* This file contains the definitions and documentation for the common /* This file contains the definitions and documentation for the common
tree codes used in the GNU C and C++ compilers (see c-common.def tree codes used in the GNU C and C++ compilers (see c-common.def
for the standard codes). for the standard codes).
Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
Written by Benjamin Chelf (chelf@codesourcery.com). Written by Benjamin Chelf (chelf@codesourcery.com).
This file is part of GCC. This file is part of GCC.
...@@ -424,16 +424,20 @@ void ...@@ -424,16 +424,20 @@ void
genrtl_while_stmt (t) genrtl_while_stmt (t)
tree t; tree t;
{ {
tree cond; tree cond = WHILE_COND (t);
emit_nop (); emit_nop ();
emit_line_note (input_filename, lineno); emit_line_note (input_filename, lineno);
expand_start_loop (1); expand_start_loop (1);
genrtl_do_pushlevel (); genrtl_do_pushlevel ();
cond = expand_cond (WHILE_COND (t)); if (cond && !integer_nonzerop (cond))
emit_line_note (input_filename, lineno); {
expand_exit_loop_top_cond (0, cond); cond = expand_cond (cond);
genrtl_do_pushlevel (); emit_line_note (input_filename, lineno);
expand_exit_loop_top_cond (0, cond);
genrtl_do_pushlevel ();
}
expand_stmt (WHILE_BODY (t)); expand_stmt (WHILE_BODY (t));
...@@ -522,7 +526,7 @@ void ...@@ -522,7 +526,7 @@ void
genrtl_for_stmt (t) genrtl_for_stmt (t)
tree t; tree t;
{ {
tree cond; tree cond = FOR_COND (t);
const char *saved_filename; const char *saved_filename;
int saved_lineno; int saved_lineno;
...@@ -539,7 +543,6 @@ genrtl_for_stmt (t) ...@@ -539,7 +543,6 @@ genrtl_for_stmt (t)
else else
expand_start_loop (1); expand_start_loop (1);
genrtl_do_pushlevel (); genrtl_do_pushlevel ();
cond = expand_cond (FOR_COND (t));
/* Save the filename and line number so that we expand the FOR_EXPR /* Save the filename and line number so that we expand the FOR_EXPR
we can reset them back to the saved values. */ we can reset them back to the saved values. */
...@@ -547,12 +550,15 @@ genrtl_for_stmt (t) ...@@ -547,12 +550,15 @@ genrtl_for_stmt (t)
saved_lineno = lineno; saved_lineno = lineno;
/* Expand the condition. */ /* Expand the condition. */
emit_line_note (input_filename, lineno); if (cond && !integer_nonzerop (cond))
if (cond) {
expand_exit_loop_top_cond (0, cond); cond = expand_cond (cond);
emit_line_note (input_filename, lineno);
expand_exit_loop_top_cond (0, cond);
genrtl_do_pushlevel ();
}
/* Expand the body. */ /* Expand the body. */
genrtl_do_pushlevel ();
expand_stmt (FOR_BODY (t)); expand_stmt (FOR_BODY (t));
/* Expand the increment expression. */ /* Expand the increment expression. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment