This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Gcc extra alignment..


On Tue, Oct 31, 2000 at 12:08:15PM -0800, Linus Torvalds wrote:
> Might it not be worth-while to special-case the "do { } while (0)"
> construct and get rid of the "loop" very very early? It's pretty much the
> standard way of writing just about any macro.

Yep, that does seem worth while.


r~


	* c-semantics.c (genrtl_do_stmt): Special case do/while(0).

Index: c-semantics.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-semantics.c,v
retrieving revision 1.10
diff -c -p -d -r1.10 c-semantics.c
*** c-semantics.c	2000/10/29 02:26:16	1.10
--- c-semantics.c	2000/11/01 01:27:29
*************** void
*** 480,498 ****
  genrtl_do_stmt (t)
       tree t;
  {
!   tree cond;
!   emit_nop ();
!   emit_line_note (input_filename, lineno);
!   expand_start_loop_continue_elsewhere (1);
  
!   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 ();
  }
  
  /* Build the node for a return statement and return it. */
--- 480,507 ----
  genrtl_do_stmt (t)
       tree t;
  {
!   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_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. */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]