Improved flag testing
authorGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Wed, 5 Feb 2003 17:34:30 +0000 (17:34 +0000)
committerGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Wed, 5 Feb 2003 17:34:30 +0000 (17:34 +0000)
[r743]

ir/ir/irflag.c
ir/ir/irflag.h
ir/ir/irgopt.c
ir/ir/irgopt.h

index 5f63e29..81e9ab5 100644 (file)
@@ -28,6 +28,7 @@ int opt_unreachable_code = 1;       /* Bad node propagation */
 int opt_control_flow_straightening = 1;           /*  */
 int opt_control_flow_weak_simplification = 1;           /*  */
 int opt_control_flow_strong_simplification = 1;           /*  */
 int opt_control_flow_straightening = 1;           /*  */
 int opt_control_flow_weak_simplification = 1;           /*  */
 int opt_control_flow_strong_simplification = 1;           /*  */
+int opt_critical_edges = 1;
 int opt_dead_node_elimination = 1;  /* Reclaim memory */
 int opt_reassociation = 1;          /* Reassociate nodes */
 int opt_inline = 1;                 /* Do inlining transformation */
 int opt_dead_node_elimination = 1;  /* Reclaim memory */
 int opt_reassociation = 1;          /* Reassociate nodes */
 int opt_inline = 1;                 /* Do inlining transformation */
@@ -83,6 +84,7 @@ INLINE void set_opt_control_flow(int value) {
   set_opt_control_flow_straightening(value);
   set_opt_control_flow_weak_simplification(value);
   set_opt_control_flow_strong_simplification(value);
   set_opt_control_flow_straightening(value);
   set_opt_control_flow_weak_simplification(value);
   set_opt_control_flow_strong_simplification(value);
+  set_opt_critical_edges(value);
 }
 
 /* Performs Straightening */
 }
 
 /* Performs Straightening */
@@ -107,6 +109,13 @@ int  get_opt_control_flow_strong_simplification(void) {
   return opt_control_flow_strong_simplification;
 }
 
   return opt_control_flow_strong_simplification;
 }
 
+void set_opt_critical_edges(int value) {
+  opt_critical_edges = value;
+}
+int  get_opt_critical_edges(void) {
+  return opt_critical_edges;
+}
+
 
 INLINE void
 set_opt_reassociation(int value)
 
 INLINE void
 set_opt_reassociation(int value)
index 30efef3..a3a77df 100644 (file)
@@ -74,7 +74,7 @@ int  get_opt_unreachable_code(void);
  *
  * Performs Straightening, if simplifications and loop simplifications.
  * Sets all separate control flow flags (control_flow_straightening,
  *
  * Performs Straightening, if simplifications and loop simplifications.
  * Sets all separate control flow flags (control_flow_straightening,
- * weak_simplification and strong_simplification).
+ * weak_simplification, strong_simplification and critical_edges).
  */
 void set_opt_control_flow(int value);
 
  */
 void set_opt_control_flow(int value);
 
@@ -93,6 +93,11 @@ void set_opt_control_flow_strong_simplification(int value);
 /** Returns strong if and loop simplification setting */
 int  get_opt_control_flow_strong_simplification(void);
 
 /** Returns strong if and loop simplification setting */
 int  get_opt_control_flow_strong_simplification(void);
 
+/** Enables/Disables removal of critical control flow edges. */
+void set_opt_critical_edges(int value);
+/** Returns whether critical edges are removed */
+int  get_opt_critical_edges(void);
+
 /** Enables/Disables reassociation.
  *
  * If opt_reassociation == 1 reassociation is performed.
 /** Enables/Disables reassociation.
  *
  * If opt_reassociation == 1 reassociation is performed.
index eac14d9..81c92a7 100644 (file)
@@ -1454,8 +1454,17 @@ void optimize_cf(ir_graph *irg) {
 }
 
 
 }
 
 
-/* Called by walker of remove_critical_cf_edges. */
-void walk_critical_cf_edges(ir_node *n, void *env) {
+/**
+ * Called by walker of remove_critical_cf_edges.
+ *
+ * Place an empty block to an edge between a blocks of multiple
+ * predecessors and a block of multiple sucessors.
+ *
+ * @param n IR node
+ * @param env Envirnment of walker. This field is unused and has
+ *            the value NULL.
+ */
+static void walk_critical_cf_edges(ir_node *n, void *env) {
   int arity, i;
   ir_node *pre, *block, **in, *jmp;
 
   int arity, i;
   ir_node *pre, *block, **in, *jmp;
 
@@ -1468,29 +1477,25 @@ void walk_critical_cf_edges(ir_node *n, void *env) {
       pre = get_irn_n(n, i);
       /* Predecessor has multiple sucessors. Insert new flow edge */
       if ((NULL != pre) && (op_Proj == get_irn_op(pre))) {
       pre = get_irn_n(n, i);
       /* Predecessor has multiple sucessors. Insert new flow edge */
       if ((NULL != pre) && (op_Proj == get_irn_op(pre))) {
-       /* set predeseccor arry for new block */
+
+       /* set predeseccor array for new block */
        in = NEW_ARR_D (ir_node *, current_ir_graph->obst, 1);
        /* set predecessor of new block */
        in[0] = pre;
        block = new_Block(1, in);
        in = NEW_ARR_D (ir_node *, current_ir_graph->obst, 1);
        /* set predecessor of new block */
        in[0] = pre;
        block = new_Block(1, in);
-       /* insert new jmp to new block */
+       /* insert new jmp node to new block */
        switch_block(block);
        jmp = new_Jmp();
        switch_block(n);
        /* set sucessor of new block */
        set_irn_n(n, i, jmp);
        switch_block(block);
        jmp = new_Jmp();
        switch_block(n);
        /* set sucessor of new block */
        set_irn_n(n, i, jmp);
+
       } /* predecessor has multiple sucessors */
     } /* for all predecessors */
   } /* n is a block */
 }
 
       } /* predecessor has multiple sucessors */
     } /* for all predecessors */
   } /* n is a block */
 }
 
-/** Placed an empty basic block on critical control flow edges thereby
-   removing them.
-   A critical control flow edge is an edge from a block with several
-   control exits to a block with several control entries (See Muchnic
-   p. 407).
-   @param irg IR Graph
-*/
 void remove_critical_cf_edges(ir_graph *irg) {
 void remove_critical_cf_edges(ir_graph *irg) {
-  irg_walk_graph(irg, NULL, walk_critical_cf_edges, NULL);
+  if (get_opt_critical_edges())
+    irg_walk_graph(irg, NULL, walk_critical_cf_edges, NULL);
 }
 }
index e61a3f9..58a19e6 100644 (file)
@@ -114,12 +114,15 @@ void place_code(ir_graph *irg);
  */
 void optimize_cf(ir_graph *irg);
 
  */
 void optimize_cf(ir_graph *irg);
 
+
 /** Places an empty basic block on critical control flow edges thereby
    removing them.
 /** Places an empty basic block on critical control flow edges thereby
    removing them.
-
    A critical control flow edge is an edge from a block with several
    control exits to a block with several control entries (See Muchnic
    A critical control flow edge is an edge from a block with several
    control exits to a block with several control entries (See Muchnic
-   p. 407).  */
+   p. 407).
+   Is only executed if flag set_opt_critical_edges() is set.
+   @param irg IR Graph
+*/
 void remove_critical_cf_edges(ir_graph *irg);
 
 # endif /* _IRGOPT_H_ */
 void remove_critical_cf_edges(ir_graph *irg);
 
 # endif /* _IRGOPT_H_ */