This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

Re: [ast-optimizer-branch] Goto/Break/Continue/Switch elimination


Hi,
This patch corrects some comments and adds the -fgoto-break-elimination flag.
Hope that I've not missed some lines with more than 80 chars.

Seb.


2002-05-02  Sebastian Pop  <s.pop@laposte.net>

	* invoke.texi : Add documentation for -fgoto-break-elimination
	* c-decl.c (c_expand_body): Control break/goto elimination by a flag.
	* toplev.c (flag_goto_break_elimination): New global variable.
	* flags.h (flag_goto_break_elimination): Declare.
	* simple-break-elim.c, simple-goto-elim.c, tree-dchain.h: Fix comments
	and wraps lines before the 80th column.


Index: invoke.texi
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.39.4.14
diff -c -r1.39.4.14 invoke.texi
*** invoke.texi	6 May 2002 12:23:25 -0000	1.39.4.14
--- invoke.texi	7 May 2002 19:51:47 -0000
***************
*** 3658,3663 ****
--- 3658,3669 ----
  Single Assignment form (SSA). @emph{Note:} This feature is under
  development and should not be used in this version of GCC.
  
+ @item -fgoto-break-elimination
+ Transforms all goto, break, continue and switch statements into a 
+ regular control flow.  It works on SIMPLE trees and thus is enabled 
+ only when the -ftree-ssa is on. @emph{Note:} This feature is under
+ development and should not be used in this version of GCC.
+ 
  @item -funroll-loops
  @opindex funroll-loops
  Unroll loops whose number of iterations can be determined at compile
Index: c-decl.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.239.2.15
diff -c -r1.239.2.15 c-decl.c
*** c-decl.c	6 May 2002 15:53:43 -0000	1.239.2.15
--- c-decl.c	7 May 2002 19:49:34 -0000
***************
*** 6838,6850 ****
        /* Simplify the function.  */
        simplify_tree (fndecl);
  
! #if 0
!       /* Transform BREAK_STMTs, CONTINUE_STMTs, SWITCH_STMTs and GOTO_STMTs.  */
!       double_chain_stmts (fn);
!       break_continue_elimination (fndecl);
!       goto_elimination (fndecl);
!       double_chain_free (fn);
! #endif
  
        /* Debugging dump after simplification.  */
        if (dump_file)
--- 6838,6852 ----
        /* Simplify the function.  */
        simplify_tree (fndecl);
  
!       if (flag_goto_break_elimination)
! 	{
! 	  /* Transform BREAK_STMTs, CONTINUE_STMTs, SWITCH_STMTs and GOTO_STMTs.  */
! 	  double_chain_stmts (fn);
! 	  break_continue_elimination (fndecl);
! 	  goto_elimination (fndecl);
! 	  double_chain_free (fn);
! 	  print_c_tree (stderr, fn);
! 	}
  
        /* Debugging dump after simplification.  */
        if (dump_file)
Index: toplev.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.494.2.9
diff -c -r1.494.2.9 toplev.c
*** toplev.c	6 May 2002 12:20:51 -0000	1.494.2.9
--- toplev.c	7 May 2002 19:52:14 -0000
***************
*** 856,861 ****
--- 856,864 ----
  /* Enable the SSA tree optimizer.  */
  int flag_tree_ssa = 0;
  
+ /* Enable goto and break elimination.  */
+ int flag_goto_break_elimination = 0;
+ 
  /* Values of the -falign-* flags: how much to align labels in code.
     0 means `use default', 1 means `don't align'.
     For each variable, there is an _log variant which is the power
***************
*** 1156,1161 ****
--- 1159,1166 ----
     N_("Trap for signed overflow in addition / subtraction / multiplication") },
    { "tree-ssa", &flag_tree_ssa, 1,
     N_("Enable SSA optimizations on trees") },
+   { "goto-break-elimination", &flag_goto_break_elimination, 1,
+    N_("Enable goto and break elimination on trees") },
  };
  
  /* Table of language-specific options.  */
Index: flags.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/flags.h,v
retrieving revision 1.65.4.6
diff -c -r1.65.4.6 flags.h
*** flags.h	2 Apr 2002 15:25:32 -0000	1.65.4.6
--- flags.h	7 May 2002 19:52:43 -0000
***************
*** 648,653 ****
--- 648,656 ----
  /* Enable the SSA tree optimizer.  */
  extern int flag_tree_ssa;
  
+ /* Enable goto and break elimination.  */
+ extern int flag_goto_break_elimination;
+ 
  /* Nonzero means put zero initialized data in the bss section.  */
  extern int flag_zero_initialized_in_bss;
  
Index: simple-break-elim.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/Attic/simple-break-elim.c,v
retrieving revision 1.1.2.1
diff -d -u -p -r1.1.2.1 simple-break-elim.c
--- simple-break-elim.c	6 May 2002 15:53:44 -0000	1.1.2.1
+++ simple-break-elim.c	7 May 2002 19:57:13 -0000
@@ -34,9 +34,9 @@ Software Foundation, 59 Temple Place - S
    After this pass we obtain a subset of the SIMPLE grammar since all 
    SWITCH_STMTs are trasformed into IF_STMTs.  */
 
-/* For normalizing the flow in the loop body, there are two approaches :
+/* For normalizing the flow in the loop body, there are two approaches:
    Solution 1: copy statements (explicit control flow).
-   Solution 2: use logical variables (data controled flow).
+   Solution 2: use logical variables (data controlled flow).
 
    The first solution raises a difficult problem linked to the visibility of a
    variable in different scopes.  
@@ -45,14 +45,14 @@ Software Foundation, 59 Temple Place - S
    eliminating GOTO_STMTs.  They describe an algorithm for eliminating goto 
    statements, but they use BREAK_STMTs for exiting loops.  The following 
    implementation is an extension of their algorithm and is based on the same 
-   principle : the use of logical variables for controlling the control flow.
+   principle: the use of logical variables for controlling the control flow.
    
-   References :
-   - Taming Control Flow : A structured	Approach to Eliminate Goto Statements,
+   References:
+   - Taming Control Flow: A structured Approach to Eliminate Goto Statements,
    Ana M. Erosa and Laurie J. Hendren, in the proceedings of the 1994 
    International Conference on Computer Languages (ICCL'94) pp.229-240. 
 
-   - Erosa's MSc. Thesis, University McGill : 
+   - Erosa's MSc. Thesis, University McGill: 
    A goto-elimination method and its implementation for the McCAT C compiler,
    http://www.sable.mcgill.ca/~hendren/ftp/erosa/thesis.ps.gz  */
 
@@ -67,8 +67,8 @@ static void break_continue_elimination_r
 static void break_elimination              PARAMS ((tree));
 static void continue_stmt_solution2        PARAMS ((tree *));
 static void break_stmt_solution2           PARAMS ((tree *));
-static void outward_motion                 PARAMS ((tree, tree, tree, 
-						    void (*) PARAMS ((tree, tree, tree, tree))));
+static void outward_motion PARAMS ((tree, tree, tree, 
+				    void (*) PARAMS ((tree, tree, tree, tree))));
 static void update_break_paths             PARAMS ((tree, tree, tree, tree));
 static void switch_to_if                   PARAMS ((tree));
 static void construct_body_for_case_labels PARAMS ((tree));
@@ -82,7 +82,8 @@ static PATH_TYPE PATH_TOP;
 
 
 /* Entry point to the break and continue elimination pass.  FN is the 
-   FUNCTION_DECL node for the function we want to simplify.  */
+   FUNCTION_DECL node for the function we want to eliminate break statements,
+   continue statements and switch statements.  */
 
 void
 break_continue_elimination (fn)
@@ -428,18 +429,18 @@ insert_orif_in_condition (condition, par
    the CONTINUE_STMT in the parent block will be executed or not.
    This solution avoids to expand the code, but the control flow 
    is no more explicit since the control depends on the logical 
-   variables : we transformed the control flow in a data flow.
+   variables: we transformed the control flow in a data flow.
    This is the solution adopted by the McCAT compiler.  
 
-   Example : "while (c) {s1; s2; continue; s3;}"
+   Example: "while (c) {s1; s2; continue; s3;}"
    Calling continue_stmt_solution2 (continue);
-   transforms the previous while into the following :
+   transforms the previous while into the following:
    "while (c) {s1; s2;}"  if "s3;" doesn't contain LABEL_STMTs (entry points),
    "while (c) {s1; s2; if (1 == 0) {s3;}"  otherwise.  
    
-   Example : "while (c1) {s1; if (c2) {s2; continue; s3;} s4;}"
+   Example: "while (c1) {s1; if (c2) {s2; continue; s3;} s4;}"
    Calling continue_stmt_solution2 (continue);
-   transforms the previous while into the following :
+   transforms the previous while into the following:
    "while (c1) {int t=0; s1; if (c2) {s2; t=1;} if (t==0) {s4;}}" 
    if there are no entry points in s3,
    "while (c1) {int t=0; s1; if (c2) {s2; t=1; if (1==0) {s3;}} if (t==0) {s4;}}" 
@@ -465,24 +466,23 @@ continue_stmt_solution2 (stmt)
   
   /* Move the flow down to the end of the related_loop's body.  */
   if (one_if == 0)
-    /* The CONTINUE_STMT is unconditional.  The logical variable is always true.  
-       That will allow outward_motion to eliminate dead code in some cases.  */
     {
-      tree prev;
+      /* The CONTINUE_STMT is unconditional.  */
+      tree prev, loop_body;
       prev = PREV_STMT (*stmt);
-
-      /* Move the flow out up to the end of the related_loop's body. 
-	 Stop before we move the flow out of related_parent : that's a CONTINUE_STMT.  */
-      flow_out_of (/* Exit the loop's body, don't exit the loop.  */ PATH_CHILD (related_parent), 
-		   PATH_TOP, 
-		   /* Delete the CONTINUE_STMT.  */ prev,
-		   /* Allow code elimination.  */ integer_one_node, 
-		   /* Updating function */ update_break_paths);
+      loop_body = PATH_CHILD (related_parent);
+      
+      /* Move the flow out up to the end of the related_loop's body.  Stop 
+	 before moving the flow out of related_parent: we eliminate a 
+	 CONTINUE_STMT.  The logical variable is always true.  That will allow
+	 outward_motion to eliminate dead code in some cases.  */
+      flow_out_of (loop_body, PATH_TOP, prev, integer_one_node, 
+		   update_break_paths);
       *stmt = prev;
     }
   else
-    /* The CONTINUE_STMT is conditional.  */
     {
+      /* The CONTINUE_STMT is conditional.  */
       tree lvar, lvar_one;
       
       /* Initialise a logical variable to false at the beginning of the loop.  */
@@ -497,8 +497,10 @@ continue_stmt_solution2 (stmt)
       *stmt = lvar_one;
       
       /* Move the flow down to the end of the related_loop's body. 
-	 Stop before we move the flow out of related_parent : that's a CONTINUE_STMT.  */
-      flow_out_of (PATH_CHILD (related_parent), PATH_TOP, lvar_one, lvar, update_break_paths);
+	 Stop before we move the flow out of related_parent: that's a 
+	 CONTINUE_STMT.  */
+      flow_out_of (PATH_CHILD (related_parent), PATH_TOP, lvar_one, lvar, 
+		   update_break_paths);
     }
 }
 
@@ -518,15 +520,18 @@ continue_stmt_solution2 (stmt)
    the BREAK_STMT in the parent block will be executed or not.
    This solution avoids to expand the code, but the control flow 
    is no more explicit since the control depends on the logical 
-   variables : we transformed the control flow in a data flow.
+   variables: we transformed the control flow in a data flow.
    This is the solution adopted by the McCAT compiler.  
 
-   Example : "while (c1) {s1; if (c2) {s2; break_stmt; s3;} s4;}"
+   Example: "while (c1) {s1; if (c2) {s2; break_stmt; s3;} s4;}"
    Calling break_stmt_solution2 (break_stmt);
-   transforms the previous while into the following :
+   transforms the previous while into the following:
+
    "int t=0; while (t==0 && c1) {s1; if (c2) {s2; t=1;} if (t==0) {s4;}}" 
    if there are no entry points in s3,
-   "int t=0; while (t==0 && c1) {s1; if (c2) {s2; t=1; if (1==0) {s3;}} if (t==0) {s4;}}" 
+
+   "int t=0; 
+   while (t==0 && c1) {s1; if (c2) {s2; t=1; if (1==0) {s3;}} if (t==0) {s4;}}" 
    if there's an entry point in s3.  */
 
 static void 
@@ -563,17 +568,17 @@ break_stmt_solution2 (stmt)
   }
   
   if (one_if == 0)
-    /* The BREAK_STMT is unconditional.  The logical variable is always true.  
-       That will allow outward_motion to eliminate dead code in some cases.  */
     {
+      /* The BREAK_STMT is unconditional.  The logical variable is always true.  
+	 That will allow outward_motion to eliminate dead code in some cases.  */
       flow_out_of (PATH_CHILD (related_parent), PATH_TOP, lvar_one, 
 		   integer_one_node, update_break_paths);
 
       /* Remove the FOR_EXPR, since when we break a loop we don't want to 
 	 reevaluate it again.  After the break elimination, we exit the FOR_STMT 
-	 after the evaluation of its FOR_COND.  If the loop contains a BREAK_STMT, 
-	 then we evaluate the FOR_EXPR before exiting the FOR_STMT, and that is
-	 not the exact semantic of a BREAK_STMT.  */
+	 after the evaluation of its FOR_COND.  If the loop contains a 
+	 BREAK_STMT, then we evaluate the FOR_EXPR before exiting the FOR_STMT, 
+	 and that is not the exact semantic of a BREAK_STMT.  */
       REMOVE_FOR_EXPR (related_loop);
 
       /* Move the flow out of related_loop.  */
@@ -583,9 +588,9 @@ break_stmt_solution2 (stmt)
     /* The BREAK_STMT is conditional.  */
     flow_out_of (related_parent, PATH_TOP, lvar_one, lvar, update_break_paths);
     
-  /* Reinitialize to false the logical variable once we have left the loop.  */
+  /* Reinitialize to false the logical variable once we have left the loop if 
+     the given related_loop is in a statement chain (not a fake loop).  */
   if (PREV_STMT (related_loop) && NEXT_STMT (related_loop))
-    /* The given related_loop is in a statement chain : it is not a fake loop.  */
     dchain_insert_stmt_after 
       (related_loop, build_stmt (EXPR_STMT, 
 				 build_modify_expr (lvar, NOP_EXPR, 
@@ -595,7 +600,7 @@ break_stmt_solution2 (stmt)
 /* If the LVAR is true, then LAST_EXECUTED is the last statement to be executed 
    in the INNER structure (that can be an IF_STMT, WHILE_STMT, ... ).  The 
    control is moved out of the OUTER structure under the control of LVAR.  
-   PATH_TYPE must be under the same implementation as the PATH defined above :
+   PATH_TYPE must be under the same implementation as the PATH defined above:
    a TREE_LIST and the inner element is the first element in the list.  */
 
 void 
@@ -632,15 +637,15 @@ flow_out_of (outer, inner, last_to_be_ex
    then we can eliminate dead code, else we insert the code following 
    LAST_EXECUTED in an 'if (0)' statement.  
 
-   Example :  "while (c) {s1; s2; s3; s4; s5;}"
+   Example:  "while (c) {s1; s2; s3; s4; s5;}"
    Calling outward_motion (WHILE_BODY (while), s3, integer_one_node) 
-   produces the following statement chain :
+   produces the following statement chain:
    "while (c) {s1; s2; s3;}"  if "s4; s5;" doesn't contain LABEL_STMTs.
    "while (c) {s1; s2; s3; if (1==0) {s4; s5;}}"  otherwise.
 
-   Example :  "while (c) {s1; s2;}"
+   Example:  "while (c) {s1; s2;}"
    Calling outward_motion (while, NULL_TREE, lvar);
-   produces the following statement chain :
+   produces the following statement chain:
    "while (lvar == 0 && c) {s1; s2;}".  */
 
 static void 
@@ -654,11 +659,12 @@ outward_motion (parent, last_executed, l
   switch (TREE_CODE (parent))
     {
     case COMPOUND_STMT:
-      /* Move the control flow at the end of the COMPOUND_BODY under the control of lvar.  */
+      /* Move the control flow at the end of the COMPOUND_BODY under the control
+	 of lvar.  */
       {
 	if (TREE_CODE (last_executed) == SCOPE_STMT 
 	    && SCOPE_END_P (last_executed))
-	  /* LAST_EXECUTED is an end scope : nothing to do.  */
+	  /* LAST_EXECUTED is an end scope: nothing to do.  */
 	  return;
 	
 	if (lvar == integer_one_node)
@@ -667,16 +673,18 @@ outward_motion (parent, last_executed, l
 	     code contains LABEL_STMTs that are potential entry points.
 	     These extra checking can be removed if we run this function 
 	     after the goto elimination.  */
-	  if (!chain_contains_stmt_p (last_executed, LABEL_STMT))
-	    /* The COMPOUND_BODY doesn't contain LABEL_STMTs after LAST_EXECUTED, 
-	       so we can safely remove this code.  */
+	  if (!chain_contains_stmt_p (last_executed, LABEL_STMT)
+	      && !chain_contains_stmt_p (last_executed, GOTO_STMT))
 	    {
-	      /* FIXME : Maybe we delete some GOTO_STMTs without deleting them
-		 from the GOTO_LIST... */
+	      /* FIXME: We cannot remove GOTO_STMTs without deleting them 
+		 from the GOTO_LIST if we're called from goto_elimination.
+		 So we can eliminate them during the break elimination, but 
+		 not during the goto_elimination.  For the moment keep things 
+		 safe: don't remove GOTO_STMTs.  */
 	      dchain_delete_stmts (last_executed, tree_last (last_executed));
 	      return;
 	    }
-
+      	
 	/* Transform the chain <LAST_EXECUTED; rest_of_code;>
 	   into <LAST_EXECUTED; if (lvar==0) {rest_of_code;}>.  */
 	eliminate_with_if (last_executed, tree_last (last_executed), lvar, 
@@ -708,8 +716,8 @@ outward_motion (parent, last_executed, l
 }
 
 /* Update all paths used in the break_elimination pass.  In fact there's nothing 
-   to do since we work only on a single path top down, whereas in goto elimination
-   we have to keep up to date a set of paths.  */
+   to do since we work only on a single path top down, whereas in goto 
+   elimination we have to keep up to date a set of paths.  */
 
 static void 
 update_break_paths (st1, st2, begin_stmt, end_stmt)
@@ -742,21 +750,22 @@ switch_to_if (stmt)
     first_case_label = NEXT_STMT (first_case_label);
   
   if (first_case_label == NULL_TREE)
-    /* There aren't CASE_LABELs in this SWITCH_STMT.  
-       We have to delete the SWITCH_STMT.  */
+    /* There aren't CASE_LABELs in this SWITCH_STMT.  We can delete the 
+       SWITCH_STMT.  */
     {
       dchain_delete_stmts (PREV_STMT (stmt), NEXT_STMT (stmt));
       return;
     }
 
   /* Step 0: Delete all unreachable statements from the last declaration up to 
-     the first case_label.  Maybe we have to warn here that there's dead code 
-     in a switch?  */
+     the first case_label.  
+     FIXME: Maybe we have to warn here that there's dead code in a switch?  */
   {
     tree last_decl;
     
     last_decl = open_scope;
-    while (TREE_CHAIN (last_decl) && TREE_CODE (TREE_CHAIN (last_decl)) == DECL_STMT)
+    while (TREE_CHAIN (last_decl) 
+	   && TREE_CODE (TREE_CHAIN (last_decl)) == DECL_STMT)
       last_decl = TREE_CHAIN (last_decl);
     
     dchain_delete_stmts (last_decl, first_case_label);
@@ -765,7 +774,7 @@ switch_to_if (stmt)
   /* Step 1: Include all statements of a CASE_LABEL in a COMPOUND_STMT.  */
   construct_body_for_case_labels (first_case_label);
   
-  /* Step 2: Copy statements from following CASE_LABELs : that simulates the 
+  /* Step 2: Copy statements from following CASE_LABELs: that simulates the 
      fall through mechanism.  Eliminate BREAK_STMTs and dead code.  */
   complete_body_of_case_labels (first_case_label);
   
@@ -778,13 +787,14 @@ switch_to_if (stmt)
   while (TREE_CODE (first_case_label) != CASE_LABEL)
     first_case_label = NEXT_STMT (first_case_label);
   
-  /* Step 4: Creates an IF_STMT for each CASE_LABEL : 
+  /* Step 4: Creates an IF_STMT for each CASE_LABEL: 
      'if (switch_cond == case_number)'.  */
   if_stmt = cases_to_if (SWITCH_COND (stmt), first_case_label);
     
   /* Step 5: Replace the SWITCH_STMT by its SWITCH_BODY in which we find all 
      local definitions and the constructed IF_STMT.  */
-  dchain_insert_chain (PREV_STMT (first_case_label), close_scope, if_stmt, if_stmt);
+  dchain_insert_chain (PREV_STMT (first_case_label), close_scope, if_stmt, 
+		       if_stmt);
   eliminate_compound_stmts (COMPOUND_BODY (switch_body));
   dchain_replace_stmt (stmt, switch_body);
 }
@@ -806,7 +816,7 @@ construct_body_for_case_labels (node)
 	/* The CASE_LABEL is followed by another CASE_LABEL.  
 	   Transform it into CASE_LABEL; COMPOUND_STMT; CASE_LABEL; with a 
 	   COMPOUND_STMT empty.  It will be filled with code copied from the 
-	   body of the next CASE_LABEL later in complete_body_of_case_labels ().  */
+	   body of the next CASE_LABEL later in complete_body_of_case_labels.  */
 	{
 	  tree compound_stmt;
 	  
@@ -824,7 +834,7 @@ construct_body_for_case_labels (node)
 	  && TREE_CODE (NEXT_STMT (node)) == COMPOUND_STMT
 	  && (TREE_CODE (NEXT_STMT (NEXT_STMT (node))) == CASE_LABEL
 	      || NEXT_STMT (NEXT_STMT (NEXT_STMT (node))) == NULL_TREE))
-	/* The case has already a COMPOUND_STMT : don't construct another one.  */
+	/* The case has already a COMPOUND_STMT: don't construct another one.  */
 	{
 	  node = case_label = NEXT_STMT (NEXT_STMT (node));
 	  continue;
@@ -850,7 +860,7 @@ construct_body_for_case_labels (node)
 	    open_scope = COMPOUND_BODY (compound_stmt);
 	    close_scope = NEXT_STMT (open_scope);
 	    
-	    /* Insert statements that belongs to the CASE_LABEL in its body.  */ 
+	    /* Insert statements that belongs to the CASE_LABEL in its body.  */
 	    dchain_insert_chain (open_scope, close_scope, 
 				 NEXT_STMT (case_label), node);
 	    
@@ -867,37 +877,38 @@ construct_body_for_case_labels (node)
     }
 }
 
-/* The following macros access a regular SWITCH_BODY : each CASE_LABEL has a 
+/* The following macros access a regular SWITCH_BODY: each CASE_LABEL has a 
    body composed of a COMPOUND_STMT.  Thus we have a chain under the following
    format: CASE_LABEL; COMPOUND_STMT; CASE_LABEL; ... COMPOUND_STMT;.  */
 #define NEXT_CASE(NODE) NEXT_STMT (NEXT_STMT (NODE))
 #define PREV_CASE(NODE) PREV_STMT (PREV_STMT (NODE))
-#define FOREACH_CASE(NODE)  for (; TREE_CODE (NODE) != SCOPE_STMT; (NODE) = NEXT_CASE (NODE))
-#define FOREACH_CASE_BOTTOM_UP(NODE)  for (; NODE && TREE_CODE (NODE) == CASE_LABEL; NODE = PREV_CASE (NODE))
-#define LAST_CASE(NODE) for (; TREE_CODE (NEXT_CASE (NODE)) == CASE_LABEL; (NODE) = NEXT_CASE (NODE))
+#define FOREACH_CASE(NODE)  \
+  for (; TREE_CODE (NODE) != SCOPE_STMT; (NODE) = NEXT_CASE (NODE))
+#define FOREACH_CASE_BOTTOM_UP(NODE)  \
+  for (; NODE && TREE_CODE (NODE) == CASE_LABEL; NODE = PREV_CASE (NODE))
+#define LAST_CASE(NODE)  \
+  for (; TREE_CODE (NEXT_CASE (NODE)) == CASE_LABEL; (NODE) = NEXT_CASE (NODE))
 #define CASE_BODY(NODE) NEXT_STMT (NODE)
 
 /* NODE is the first CASE_LABEL of a SWITCH_STMT.  This function suposes that
-   SWITCH_BODY is composed as described by the following schema :
+   SWITCH_BODY is composed as described by the following schema:
    {CASE_LABEL; COMPOUND_STMT; CASE_LABEL; COMPOUND_STMT; ... COMPOUND_STMT;}
    every CASE_LABEL is followed by a COMPOUND_STMT.  
+   
    This function completes the body of a CASE_LABEL by copying statements in 
-   order to simulate the fall through mechanism.  
-
-   FIXME: An optimized way to do this job is bottom-up : begin the completion of
-   bodies from the last CASE_LABEL and follow the PREV_STMT chain.  
-   Apply the break and dead code elimination for each CASE_LABEL body before 
-   copying the code for the PREV_CASE.  
+   order to simulate the fall through mechanism.  It begins the completion of 
+   bodies from the last CASE_LABEL and follow the PREV_STMT chain bottom-up.
+   It applies the break and dead code elimination for each CASE_BODY after
+   having copied the code from the NEXT_CASE's body. 
 
-   The transformation is done bottom-up.
-   Example of the execution of this algorithm :
+   Example of the execution of this algorithm:
    switch ()
    {
    case 1: {b1;}
    case 2: {b2;}
    case 3: {b3;}
    }
-   0. Nothing to copy : "case 3" is the last in SWITCH_BODY.
+   0. Nothing to copy: "case 3" is the last in SWITCH_BODY.
    1. Apply break/dead code elimination on {b3;} gives {a3;}.
    switch ()
    {
@@ -952,19 +963,20 @@ complete_body_of_case_labels (node)
       next_case = NEXT_CASE (node);
       
       if (TREE_CODE (next_case) == CASE_LABEL)
-	/* Copy the CASE_BODY of the next CASE_LABEL after the last 
-	   statement of the body of this CASE_LABEL.  */
 	{
+	  /* Copy the CASE_BODY of the next CASE_LABEL after the last 
+	     statement of the body of this CASE_LABEL.  */
 	  dchain_insert_stmt_after (last_stmt, 
-				    dchain_deep_copy_node (CASE_BODY (next_case)));
+				    dchain_deep_copy_node (CASE_BODY 
+							   (next_case)));
 
 	  /* Delete all LABEL_STMTs we've copied.  This way we avoid duplicated
 	     label definitions.  That is what we could call following the same
-	     terminology as McGill : 'avoid a LABEL_STMT capture'.  */
+	     terminology as McGill: 'avoid a LABEL_STMT capture'.  */
 	  dchain_delete_labels (COMPOUND_BODY (NEXT_STMT (last_stmt)));
 	}
       /* else
-	 This is the last CASE_LABEL of the SWITCH_BODY : nothing to copy.  */
+	 This is the last CASE_LABEL of the SWITCH_BODY: nothing to copy.  */
       
       /* Eliminate BREAK_STMTs and dead code.  */
       {
@@ -987,12 +999,12 @@ complete_body_of_case_labels (node)
 
 /* NODE is the first CASE_LABEL statement of a SWITCH_BODY.  
    This function suposes that a SWITCH_BODY is composed as described by the 
-   following schema :
+   following schema:
    {CASE_LABEL; COMPOUND_STMT; CASE_LABEL; COMPOUND_STMT; ... COMPOUND_STMT;}
    every CASE_LABEL is followed by a COMPOUND_STMT.  Moreover it supposes that
    there's no fall through between cases, and that all BREAK_STMTs were deleted.
    This function reorder CASE_LABELs in the SWITCH_BODY. 
-   It performs for the moment the minimum : ensure that the DEFAULT case is the
+   It performs for the moment the minimum: ensure that the DEFAULT case is the
    last case in the SWITCH_BODY.  
    Other optimisations based on the reordering of cases could be implemented 
    or rewritten (from switch_stack)*/
@@ -1006,8 +1018,8 @@ reorder_case_labels (node)
     {
       if (CASE_LOW (node) == NULL_TREE 
 	  && CASE_HIGH (node) == NULL_TREE)
-	/* That's the DEFAULT case : move it at the end of the SWITCH_BODY.  */
 	{
+	  /* That's the DEFAULT case: move it at the end of the SWITCH_BODY.  */
 	  tree default_case;
 	  default_case = node;
 
@@ -1016,8 +1028,8 @@ reorder_case_labels (node)
 	    break;
 	  
 	  /* Delete the default_case from its position.  */
-	  dchain_delete_stmts (PREV_STMT (default_case), NEXT_CASE (default_case));
-	  
+	  dchain_delete_stmts (PREV_STMT (default_case), 
+			       NEXT_CASE (default_case));
 	  /* Search the last CASE_LABEL in this SWITCH_STMT.  */
 	  LAST_CASE (node);
 	  
@@ -1038,7 +1050,7 @@ reorder_case_labels (node)
 /* NODE is a CASE_LABEL of a SWITCH_BODY.  SVAR is the SWITCH_COND. 
    This function transforms all cases of a SWITCH_STMT into a nested IF_STMT.
    This function suposes that a SWITCH_BODY is composed as described by the
-   following schema :
+   following schema:
    {CASE_LABEL; COMPOUND_STMT; ... default: COMPOUND_STMT;}
    every CASE_LABEL is followed by a COMPOUND_STMT, there's no fall through 
    between cases, all BREAK_STMTs were deleted, and the DEFAULT case is the last
@@ -1060,24 +1072,24 @@ cases_to_if (svar, node)
   low = CASE_LOW (node);
   high = CASE_HIGH (node);
   if (low && high)
-    /* Range.  */
     {
+      /* Range case: "case 2 ... 5:".  */
       tree le, ge;
       
-      /* Construct the condition : (low >= svar && svar <= high).  */
+      /* Construct the condition: (low >= svar && svar <= high).  */
       ge = build (GE_EXPR, integer_type_node, svar, low);
       le = build (LE_EXPR, integer_type_node, svar, high);
       cond = build (TRUTH_ANDIF_EXPR, integer_type_node, le, ge);
     }
   else if (low)
-    /* A normal case.  Construct the condition : (svar == low).  */
+    /* A normal case.  Construct the condition: (svar == low).  */
     cond = build (EQ_EXPR, integer_type_node, svar, low);
   else
-    /* The default case : we're on the last case of the SWITCH_BODY.  */
     {
+      /* The default case: we're on the last case of the SWITCH_BODY.  */
       else_clause = CASE_BODY (node);
 
-      /* The else_clause becomes part of the IF_STMT : remove its pointers to 
+      /* The else_clause becomes part of the IF_STMT: remove its pointers to 
 	 the statemtent chain.  */
       NEXT_STMT (else_clause) = NULL_TREE;
       PREV_STMT (else_clause) = NULL_TREE;
@@ -1088,7 +1100,7 @@ cases_to_if (svar, node)
   then_clause = CASE_BODY (node);
   else_clause = cases_to_if (svar, NEXT_CASE (node));
   
-  /* The then_clause becomes part of the IF_STMT : remove its pointers to 
+  /* The then_clause becomes part of the IF_STMT: remove its pointers to 
      the statemtent chain.  */
   NEXT_STMT (then_clause) = NULL_TREE;
   PREV_STMT (then_clause) = NULL_TREE;
@@ -1116,14 +1128,14 @@ eliminate_compound_stmts (stmt)
 	{
 	case COMPOUND_STMT:
 	  if (!SCOPE_STMT_BLOCK (COMPOUND_BODY (stmt)))
-	    /* This COMPOUND_STMT doesn't contain declarations : open it.  */
 	    {
+	      /* This COMPOUND_STMT doesn't contain declarations: open it.  */
 	      tree prev;
 	      prev = PREV_STMT (stmt);
 	      dchain_insert_chain (prev, NEXT_STMT (stmt),
-				   /* First stmt is open_scope : don't copy it.  */
+				   /* First stmt is open_scope: don't copy it.  */
 				   NEXT_STMT (COMPOUND_BODY (stmt)),
-				   /* Last stmt is close_scope : don't copy it.  */
+				   /* Last stmt is close_scope: don't copy it.  */
 				   PREV_STMT (tree_last (COMPOUND_BODY (stmt))));
 	      stmt = prev;
 	    }
@@ -1140,9 +1152,9 @@ eliminate_compound_stmts (stmt)
 	      /* Eliminate this FOR_STMT.  */
 	      dchain_delete_stmts (PREV_STMT (stmt), NEXT_STMT (stmt));
 	    else
-	      /* Keep the FOR_STMT, but eliminate unneeded COMPOUND_STMTs from
-		 its body.  */
 	      {
+		/* Keep the FOR_STMT, but eliminate unneeded COMPOUND_STMTs from
+		   its body.  */
 		dchain_build_scope (&FOR_BODY (stmt));
 		eliminate_compound_stmts (COMPOUND_BODY (FOR_BODY (stmt)));
 	      }
@@ -1156,9 +1168,9 @@ eliminate_compound_stmts (stmt)
 	      /* Eliminate this WHILE_STMT.  */
 	      dchain_delete_stmts (PREV_STMT (stmt), NEXT_STMT (stmt));
 	    else
-	      /* Keep the WHILE_STMT, but eliminate unneeded COMPOUND_STMTs from
-		 its body.  */
 	      {
+		/* Keep the WHILE_STMT, but eliminate unneeded COMPOUND_STMTs from
+		   its body.  */
 		dchain_build_scope (&WHILE_BODY (stmt));
 		eliminate_compound_stmts (COMPOUND_BODY (WHILE_BODY (stmt)));
 	      }
@@ -1169,8 +1181,8 @@ eliminate_compound_stmts (stmt)
 	  {
 	    if (eval_bool_condition (DO_COND (stmt)) == EVAL_FALSE 
 		&& !chain_contains_stmt_p (DO_BODY (stmt), LABEL_STMT))
-	      /* Eliminate this DO_STMT : keep only its DO_BODY.  */
 	      {
+		/* Eliminate this DO_STMT: keep only its DO_BODY.  */
 		dchain_replace_stmt (stmt, DO_BODY (stmt));
 		stmt = DO_BODY (stmt);
 		
@@ -1178,9 +1190,9 @@ eliminate_compound_stmts (stmt)
 		continue;
 	      }
 	    else
-	      /* Keep the DO_STMT, but eliminate unneeded COMPOUND_STMTs from
-		 its body.  */
 	      {
+		/* Keep the DO_STMT, but eliminate unneeded COMPOUND_STMTs from
+		   its body.  */
 		dchain_build_scope (&DO_BODY (stmt));
 		eliminate_compound_stmts (COMPOUND_BODY (DO_BODY (stmt)));
 		break;
@@ -1199,8 +1211,8 @@ eliminate_compound_stmts (stmt)
 	    
 	    if (evc == EVAL_TRUE 
 		&& !chain_contains_stmt_p (ELSE_CLAUSE (stmt), LABEL_STMT))
-	      /* Eliminate this IF_STMT : keep only its THEN_CLAUSE.  */
 	      {
+		/* Eliminate this IF_STMT: keep only its THEN_CLAUSE.  */
 		dchain_build_scope (&THEN_CLAUSE (stmt));
 		dchain_replace_stmt (stmt, THEN_CLAUSE (stmt));
 		stmt = THEN_CLAUSE (stmt);
@@ -1208,16 +1220,16 @@ eliminate_compound_stmts (stmt)
 	      }
 	    else if (evc == EVAL_FALSE 
 		     && !chain_contains_stmt_p (THEN_CLAUSE (stmt), LABEL_STMT))
-	      /* Eliminate this IF_STMT : keep only its ELSE_CLAUSE.  */
 	      {
+		/* Eliminate this IF_STMT: keep only its ELSE_CLAUSE.  */
 		dchain_build_scope (&ELSE_CLAUSE (stmt));
 		dchain_replace_stmt (stmt, ELSE_CLAUSE (stmt));
 		stmt = ELSE_CLAUSE (stmt);
 		continue;
 	      }
 	    else
-	      /* Keep both clauses of the IF_STMT.  */
 	      {
+		/* Keep both clauses of the IF_STMT.  */
 		dchain_build_scope (&THEN_CLAUSE (stmt));
 		dchain_build_scope (&ELSE_CLAUSE (stmt));
 		eliminate_compound_stmts (COMPOUND_BODY (THEN_CLAUSE (stmt)));
@@ -1262,8 +1274,8 @@ eval_bool_condition (expr)
 	
 	if (TREE_CODE (op0) == INTEGER_CST 
 	    && TREE_CODE (op1) == INTEGER_CST)
-	  /* Both operands are integers.  */
 	  {
+	    /* Both operands are integers.  */
 	    int i0, i1;
 	    i0 = TREE_INT_CST_LOW (op0);
 	    i1 = TREE_INT_CST_LOW (op1);
Index: simple-goto-elim.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/Attic/simple-goto-elim.c,v
retrieving revision 1.1.2.1
diff -d -u -p -r1.1.2.1 simple-goto-elim.c
--- simple-goto-elim.c	6 May 2002 15:53:44 -0000	1.1.2.1
+++ simple-goto-elim.c	7 May 2002 20:09:46 -0000
@@ -59,14 +59,14 @@ Software Foundation, 59 Temple Place - S
    and have to be transformed before this pass (break_continue_elimination pass).
    
 
-   References :
+   References:
 
-   - Taming Control Flow : A structured	Approach to Eliminate Goto Statements,
+   - Taming Control Flow: A structured	Approach to Eliminate Goto Statements,
    Ana M. Erosa and Laurie J. Hendren, in the proceedings of the 1994 
    International Conference on Computer Languages (ICCL'94) pp.229-240. 
    ftp://ftp-acaps.cs.mcgill.ca/pub/doc/papers/ICCL94.ps.gz
 
-   - Erosa's MSc. Thesis, University McGill : 
+   - Erosa's MSc. Thesis, University McGill: 
    A goto-elimination method and its implementation for the McCAT C compiler,
    http://www.sable.mcgill.ca/~hendren/ftp/erosa/thesis.ps.gz  */
 
@@ -314,7 +314,7 @@ find_labels_gotos (node)
 
 	case SWITCH_STMT:
 	  /* This implementation of goto_elimination doesn't handle this type of
-	     statement : it works on a subset of SIMPLE that doesn't contain 
+	     statement: it works on a subset of SIMPLE that doesn't contain 
 	     SWITCH_STMTs.  This subset of SIMPLE is obtained after the 
 	     break_continue_elimination.  Run this pass before the goto_elimination.
 	     The main reason for this limitation is that implementating this pass
@@ -366,7 +366,7 @@ find_labels_gotos (node)
 			    (NEXT_STMT 
 			     (COMPOUND_BODY 
 			      (THEN_CLAUSE (node))))) == SCOPE_STMT)
-	    /* That's a conditionnal goto : "if (cond) {goto L;}".  */
+	    /* That's a conditionnal goto: "if (cond) {goto L;}".  */
 	    GOTO_PUSH (node);
 	  else
 	    {
@@ -446,20 +446,20 @@ transform_gotos ()
 {
   gotol prev_g = NULL;
   
-  /* Eliminate GOTO_STMTs one by one.  */
+  /* Eliminate GOTO_STMTs one by one.  G:= select a goto from GOTO_LIST.  */
   GOTO_FOREACH (g, goto_list)
-    /* G := select a goto from GOTO_LIST.  */
     {
       enum rel r;
       tree goto_in;
 
       GOTO_POP ();
       if (prev_g)
-	/* No more need this element : free it.  */
+	/* No more need this element: free it.  */
 	DELETE (prev_g);
       
-      /* L := label matching G.  */
-      l = label_hash_lookup (IDENTIFIER_POINTER (DECL_NAME (GOTO_LABEL (g))), false);
+      /* L:= label matching G.  */
+      l = label_hash_lookup (IDENTIFIER_POINTER (DECL_NAME (GOTO_LABEL (g))), 
+			     false);
       
       goto_in = GOTO_IF_STMT (g);
       
@@ -485,8 +485,9 @@ transform_gotos ()
 	case DIRECTLY_RELATED:
 	  /* Either the goto or the label is nested in some statements.  */
 	  if (r == DIRECTLY_RELATED && (GOTO_LEVEL (g) > LABEL_LEVEL (l)))
-	    /* The goto is nested.  Move it out to the same level as its LABEL_STMT.  */
 	    {
+	      /* The goto is nested.  Move it out to the same level as its 
+		 LABEL_STMT.  */
 	      PATH_TYPE oncp;
 	      oncp = outer_non_common_parent ();
 	      
@@ -499,31 +500,37 @@ transform_gotos ()
 	      /* ... fall through in SIBLINGS ...  */
 	    }
 	  else
-	    /* Here the GOTO_STMT is guaranteed to be in GCP's scope.  We have 
-	       to move the GOTO_STMT in LABEL_STMT's scope using inward motion.  */
 	    {
+	      /* Here the GOTO_STMT is guaranteed to be in GCP's scope.  We 
+		 have to move the GOTO_STMT in LABEL_STMT's scope using inward
+		 motion.  */
 	      PATH_TYPE label_in;
 	      
 	      /* Step 1: Identify in label's path the common parent from where
-		 to start the inward motion : this pointer is called LABEL_IN.  
+		 to start the inward motion: this pointer is called LABEL_IN.  
 		 Note that here we get a pointer to LABEL_PATH that we will 
 		 follow for the inward motion.  */
 	      label_in = great_common_parent ();
 	      
 	      if (TREE_CODE (PATH_STMT (PATH_PARENT (label_in))) == IF_STMT 
-		  && (goto_in == THEN_CLAUSE (PATH_STMT (PATH_PARENT (label_in))) 
-		      || goto_in == ELSE_CLAUSE (PATH_STMT (PATH_PARENT (label_in)))))
-		/* g and l were INDIRECTLY_RELATED in 2 different clauses of an IF_STMT.  */
+		  && (goto_in == THEN_CLAUSE (PATH_STMT 
+					      (PATH_PARENT (label_in))) 
+		      || goto_in == ELSE_CLAUSE (PATH_STMT 
+						 (PATH_PARENT (label_in)))))
 		{
+		  /* g and l were INDIRECTLY_RELATED in 2 different clauses of 
+		     an IF_STMT.  */
 		  tree parent_stmt;
 		  label_in = PATH_PARENT (label_in);
 		  parent_stmt = PATH_STMT (label_in);
-		  goto_in = eliminate_with_do (parent_stmt, parent_stmt, GOTO_LVAR (g));
+		  goto_in = eliminate_with_do (parent_stmt, parent_stmt,
+					       GOTO_LVAR (g));
 		}
 	      else if (GOTO_OFFSET (g) > LABEL_OFFSET (l))
-		/* The GOTO_STMT is after the LABEL_STMT : lift the GOTO_STMT
+		/* The GOTO_STMT is after the LABEL_STMT: lift the GOTO_STMT
 		   before the LABEL_STMT.  */
-		goto_in = eliminate_with_do (PATH_STMT (label_in), goto_in, GOTO_LVAR (g));
+		goto_in = eliminate_with_do (PATH_STMT (label_in), goto_in, 
+					     GOTO_LVAR (g));
 	      
 	      /* Moves the GOTO_STMT in LABEL_STMT's scope, then eliminates it.  */
 	      goto_in = flow_in (label_in, goto_in, GOTO_LVAR (g));
@@ -548,31 +555,31 @@ transform_gotos ()
     }
 
   if (prev_g)
-    /* No more need this element : free it.  */
+    /* No more need this element: free it.  */
     DELETE (prev_g);
 }
 
 /* Determine how a LABEL_STMT and a GOTO_STMT are related.  There are three
-   cases : SIBLINGS, DIRECTLY_RELATED, and INDIRECTLY_RELATED.
+   cases: SIBLINGS, DIRECTLY_RELATED, and INDIRECTLY_RELATED.
 
-   Def1 : A LABEL_STMT and a GOTO_STMT are SIBLINGS if there exist some statement
+   Def1: A LABEL_STMT and a GOTO_STMT are SIBLINGS if there exist some statement
    sequence stmt_1; ... stmt_n; such that the LABEL_STMT corresponds to stmt_i 
    and the GOTO_STMT corresponds to stmt_j in the statement sequence.
 
-   Def2 : A LABEL_STMT and a GOTO_STMT are DIRECTLY_RELATED if there exist some 
+   Def2: A LABEL_STMT and a GOTO_STMT are DIRECTLY_RELATED if there exist some 
    statement sequence stmt_1; ... stmt_n; such that either the LABEL_STMT or 
    the GOTO_STMT corresponds to stmt_i and the matching GOTO_STMT or LABEL_STMT
    is nested inside some stmt_j in the statement sequence.
 
-   Def3 : A LABEL_STMT and a GOTO_STMT are INDIRECTLY_RELATED if they appear in
+   Def3: A LABEL_STMT and a GOTO_STMT are INDIRECTLY_RELATED if they appear in
    the same procedure body, but they are neither siblings, nor directly related.  */
 
 static enum rel
 related ()
 {
   if (GOTO_LEVEL (g) == LABEL_LEVEL (l))
-    /* Both at the same nesting level,  */
     {
+      /* Both at the same nesting level,  */
       if (GOTO_OFFSET (g) < LABEL_OFFSET (l))
 	{
 	  tree it;
@@ -594,7 +601,7 @@ related ()
 	       it = NEXT_STMT (it))
 	    {
 	      if (it == GOTO_IF_STMT (g))
-		/* && GOTO_STMT reachable from LABEL_STMT by CHAIN.  */
+		/* and GOTO_STMT reachable from LABEL_STMT by CHAIN.  */
 		return SIBLINGS;
 	    }
 	  return INDIRECTLY_RELATED;
@@ -606,8 +613,8 @@ related ()
     return DIRECTLY_RELATED;
 
   else
-    /* Not at the same nesting level.  */
     {
+      /* Not at the same nesting level.  */
       PATH_TYPE gp, lp;
       
       gp = PATH_ANCESTOR (GOTO_PATH (g));
@@ -638,7 +645,7 @@ outer_non_common_parent ()
 {
   PATH_TYPE gp, lp;
   
-  /* Begin the search from the outer COMPOUND_STMT : function's level.  */
+  /* Begin the search from the outer COMPOUND_STMT: function's level.  */
   gp = PATH_ANCESTOR (GOTO_PATH (g));
   lp = PATH_ANCESTOR (LABEL_PATH (l));
   
@@ -658,7 +665,7 @@ great_common_parent ()
 {
   PATH_TYPE gp, lp;
   
-  /* Begin the search from the outer COMPOUND_STMT : function's level.  */
+  /* Begin the search from the outer COMPOUND_STMT: function's level.  */
   gp = PATH_ANCESTOR (GOTO_PATH (g));
   lp = PATH_ANCESTOR (LABEL_PATH (l));
   
@@ -695,7 +702,8 @@ flow_in (label_in, goto_in, lvar)
 	case WHILE_STMT:
 	case FOR_STMT:
 	  insert_orif_in_condition (lvar, label_in_stmt);
-	  goto_in = tree_last_decl (COMPOUND_BODY (PATH_STMT (PATH_CHILD (label_in))));
+	  goto_in = tree_last_decl (COMPOUND_BODY (PATH_STMT (PATH_CHILD 
+							      (label_in))));
 	  label_in = PATH_CHILD (PATH_CHILD (label_in));
 	  break;
 	  
@@ -707,17 +715,19 @@ flow_in (label_in, goto_in, lvar)
 	case IF_STMT:
 	  /* Determine in which clause we have to flow in.  */
 	  if (PATH_STMT (PATH_CHILD (label_in)) == THEN_CLAUSE (label_in_stmt))
-	    /* We enter the THEN_CLAUSE : "if (!lvar && condition)".  */
+	    /* We enter the THEN_CLAUSE: "if (!lvar && condition)".  */
 	    insert_orif_in_condition (lvar, label_in_stmt);
 	  else
-	    /* We enter the ELSE_CLAUSE : negate the logical variable, 
-	       that is equivalent to say "lvar==0 && ..."  */
 	    {
+	      /* We enter the ELSE_CLAUSE: negate the logical variable, 
+		 that is equivalent to say "lvar==0 && ..."  */
 	      tree not_lvar;
-	      not_lvar = build (EQ_EXPR, integer_type_node, lvar, integer_zero_node);
+	      not_lvar = build (EQ_EXPR, integer_type_node, lvar, 
+				integer_zero_node);
 	      insert_andif_in_condition (not_lvar, label_in_stmt);
 	    }
-	  goto_in = tree_last_decl (COMPOUND_BODY (PATH_STMT (PATH_CHILD (label_in))));
+	  goto_in = tree_last_decl (COMPOUND_BODY (PATH_STMT (PATH_CHILD 
+							      (label_in))));
 	  label_in = PATH_CHILD (PATH_CHILD (label_in));
 	  break;
 	  
@@ -736,8 +746,8 @@ flow_in (label_in, goto_in, lvar)
   return goto_in;
 }
 
-/* Copied from c-simplify.  Maybe we have to declare it as extern and avoid to duplicate code...
-   Returns the last DECL_STMT in the scope SCOPE.  */
+/* FIXME: Copied from c-simplify.  Maybe we have to declare it as extern and 
+   avoid to duplicate code... Returns the last DECL_STMT in the scope SCOPE.  */
 
 static tree
 tree_last_decl (scope)
@@ -775,7 +785,7 @@ eliminate_with_if (before_stmt, after_st
     return;
 
   /* Include statements that we find between BEFORE_STMT and LABEL_STMT in the
-     THEN_CLAUSE of an IF_STMT : that code is not executed when the logical 
+     THEN_CLAUSE of an IF_STMT: that code is not executed when the logical 
      variable LVAR is true.  */
   new_if = build_stmt (IF_STMT, build (EQ_EXPR, integer_type_node, lvar, 
 				       integer_zero_node), 
@@ -823,7 +833,7 @@ eliminate_with_do (before_stmt, after_st
 }
 
 /* Update all paths of labels and gotos if their offset is between G and L. 
-   ST1 and ST2 are two nodes that have to be added to the new path : they are 
+   ST1 and ST2 are two nodes that have to be added to the new path: they are 
    for example a DO_STMT and its DO_BODY if we are called from eliminate_with_do.
    All paths that contain a statement between BEGIN_STMT excluded and END_STMT
    excluded are updated.  */
@@ -834,8 +844,9 @@ update_paths_if (st1, st2, begin_stmt, e
 {
   tree it_stmt;
 
-  for (it_stmt = NEXT_STMT (begin_stmt); it_stmt != end_stmt; it_stmt = NEXT_STMT (it_stmt))
-    /* For each statement between BEFORE_STMT and AFTER_STMT,  */
+  /* For each statement between BEFORE_STMT and AFTER_STMT,  */
+  for (it_stmt = NEXT_STMT (begin_stmt); it_stmt != end_stmt; 
+       it_stmt = NEXT_STMT (it_stmt))
     {
       switch (TREE_CODE (it_stmt))
 	{
@@ -857,7 +868,9 @@ update_paths_if (st1, st2, begin_stmt, e
 		  path_include (path, st1, st2, PATH_CHILD (path));
 		
 		/* IT_L is the label associated to the goto pointed by IT_G.  */
-		it_l = label_hash_lookup (IDENTIFIER_POINTER (DECL_NAME (GOTO_LABEL (it_g))), false);
+		it_l = label_hash_lookup (IDENTIFIER_POINTER 
+					  (DECL_NAME 
+					   (GOTO_LABEL (it_g))), false);
 		path = path_contain_stmt (LABEL_PATH (it_l), it_stmt);
 		if (path)
 		{
@@ -875,7 +888,9 @@ update_paths_if (st1, st2, begin_stmt, e
 	case LABEL_STMT:
 	  {
 	    label lab;
-	    lab = label_hash_lookup (IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (it_stmt, 0))), false);
+	    lab = label_hash_lookup (IDENTIFIER_POINTER 
+				     (DECL_NAME 
+				      (TREE_OPERAND (it_stmt, 0))), false);
 
 	    path_include (LABEL_PATH (lab), st1, st2, PATH_NULL);
 	    
@@ -890,7 +905,7 @@ update_paths_if (st1, st2, begin_stmt, e
 }
 
 /* Update all paths of labels and gotos if their offset is between G and L. 
-   ST1 and ST2 are two nodes that have to be added to the new path : they are 
+   ST1 and ST2 are two nodes that have to be added to the new path: they are 
    for example a DO_STMT and its DO_BODY if we are called from eliminate_with_do.
    All paths that contain a statement between BEGIN_STMT excluded and END_STMT
    excluded are updated.  */
@@ -921,7 +936,9 @@ update_paths_do (st1, st2, begin_stmt, e
 		path_include (PATH_PARENT (path), st1, st2, path); 
 			      
 	      /* IT_L is the label associated to the goto pointed by IT_G.  */
-	      it_l = label_hash_lookup (IDENTIFIER_POINTER (DECL_NAME (GOTO_LABEL (it_g))), false);
+	      it_l = label_hash_lookup (IDENTIFIER_POINTER 
+					(DECL_NAME 
+					 (GOTO_LABEL (it_g))), false);
 	      path = path_contain_stmt (LABEL_PATH (it_l), begin_stmt);
 	      if (path)
 		{
@@ -937,7 +954,9 @@ update_paths_do (st1, st2, begin_stmt, e
       case LABEL_STMT:
 	{
 	  label lab;
-	  lab = label_hash_lookup (IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (begin_stmt, 0))), false);
+	  lab = label_hash_lookup (IDENTIFIER_POINTER 
+				   (DECL_NAME 
+				    (TREE_OPERAND (begin_stmt, 0))), false);
 	  path_include (LABEL_PATH (lab), st1, st2, PATH_NULL);
 	  LABEL_PATH (lab) = PATH_CHILD (PATH_CHILD (LABEL_PATH (lab)));
 	  break;
@@ -1034,7 +1053,7 @@ label_hash_lookup (string, create)
 }
 
 
-#if 1
+#if 0
 /* Debugging functions.  */
 static void debug_path                         PARAMS ((PATH_TYPE));
 static void debug_path_elt                     PARAMS ((PATH_TYPE));
Index: tree-dchain.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/Attic/tree-dchain.h,v
retrieving revision 1.1.2.1
diff -d -u -p -r1.1.2.1 tree-dchain.h
--- tree-dchain.h	6 May 2002 15:53:44 -0000	1.1.2.1
+++ tree-dchain.h	7 May 2002 20:11:44 -0000
@@ -82,16 +82,18 @@ extern void dchain_delete_labels        
 
 
 /* In simple-break-elim.c  */
-extern void break_continue_elimination     PARAMS ((tree));
-extern int chain_contains_stmt_p           PARAMS ((tree, enum tree_code));
-extern void flow_out_of                    PARAMS ((PATH_TYPE, PATH_TYPE, tree, tree, void (*) 
-						    PARAMS ((tree, tree, tree, tree))));
-extern void insert_andif_in_condition      PARAMS ((tree, tree));
-extern void insert_orif_in_condition       PARAMS ((tree, tree));
-extern void eliminate_compound_stmts       PARAMS ((tree));
+extern void break_continue_elimination PARAMS ((tree));
+extern int chain_contains_stmt_p       PARAMS ((tree, enum tree_code));
+extern void flow_out_of                PARAMS ((PATH_TYPE, PATH_TYPE, tree, tree, 
+						void (*) PARAMS ((tree, tree, 
+								  tree, tree))));
+extern void insert_andif_in_condition  PARAMS ((tree, tree));
+extern void insert_orif_in_condition   PARAMS ((tree, tree));
+extern void eliminate_compound_stmts   PARAMS ((tree));
 
 
 /* In simple-goto-elim.c  */
-extern void goto_elimination               PARAMS ((tree));
-extern void eliminate_with_if              PARAMS ((tree, tree, tree, 
-						    void (*) PARAMS ((tree, tree, tree, tree))));
+extern void goto_elimination           PARAMS ((tree));
+extern void eliminate_with_if          PARAMS ((tree, tree, tree, 
+						void (*) PARAMS ((tree, tree, 
+								  tree, tree))));


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