diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-11-01 01:31:06 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-11-01 01:31:06 +0000 |
commit | e0f54c0ca2fc847620498ffcafbfa62158753892 (patch) | |
tree | 55374d4a060bf50c26ed3ef478b1f462ccfa5e6e /gcc/c-semantics.c | |
parent | ad555ee47c7b36fd35603da6b0ba699aa9558aee (diff) | |
download | gcc-e0f54c0ca2fc847620498ffcafbfa62158753892.tar.gz |
* c-semantics.c (genrtl_do_stmt): Special case do/while(0).
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37177 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-semantics.c')
-rw-r--r-- | gcc/c-semantics.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/gcc/c-semantics.c b/gcc/c-semantics.c index f8528415722..ccc3c7d4e77 100644 --- a/gcc/c-semantics.c +++ b/gcc/c-semantics.c @@ -480,19 +480,28 @@ void genrtl_do_stmt (t) tree t; { - tree cond; - emit_nop (); - emit_line_note (input_filename, lineno); - expand_start_loop_continue_elsewhere (1); + tree cond = DO_COND (t); + + /* Recognize the common special-case of do { ... } while (0) and do + not emit the loop widgetry in this case. In particular this + avoids cluttering the rtl with dummy loop notes, which can affect + alignment of adjacent labels. */ + if (cond == integer_zero_node) + expand_stmt (DO_BODY (t)); + else + { + emit_nop (); + emit_line_note (input_filename, lineno); + expand_start_loop_continue_elsewhere (1); - expand_stmt (DO_BODY (t)); + expand_stmt (DO_BODY (t)); - expand_loop_continue_here (); - - cond = expand_cond (DO_COND (t)); - emit_line_note (input_filename, lineno); - expand_exit_loop_if_false (0, cond); - expand_end_loop (); + expand_loop_continue_here (); + cond = expand_cond (cond); + emit_line_note (input_filename, lineno); + expand_exit_loop_if_false (0, cond); + expand_end_loop (); + } } /* Build the node for a return statement and return it. */ |