* c-semantics.c (genrtl_do_stmt): Special case do/while(0).
authorRichard Henderson <rth@redhat.com>
Wed, 1 Nov 2000 01:31:06 +0000 (17:31 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Wed, 1 Nov 2000 01:31:06 +0000 (17:31 -0800)
From-SVN: r37177

gcc/ChangeLog
gcc/c-semantics.c

index b689ad9967f5d10239cf5afd55a2d965a47ebd52..3b12182d7d22be098ce2c0eea3f5fc3157816c1e 100644 (file)
@@ -1,3 +1,7 @@
+2000-10-31  Richard Henderson  <rth@redhat.com>
+
+       * c-semantics.c (genrtl_do_stmt): Special case do/while(0).
+
 2000-10-31  Nick Clifton  <nickc@redhat.com>
 
        * config/arm/unknown-elf.h (UNIQUE_SECTION_P): Do not allow
index f85284157227291795dcb696022795a00496c232..ccc3c7d4e7743b3365b208819609114bec5bd480 100644 (file)
@@ -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. */