Commit 7a483ab9 authored by Matthias Braun's avatar Matthias Braun
Browse files

remove opt_manage, provide assure_irg_properties

The opt_manage framework didn't really do much except assuring that some
analysis info is computed before a pass starts. We can achieve this
simpler by providing an assure_irg_properties function.
This commit also fixes some places where analysis info was potentially
not invalidated before.
parent 18329a03
...@@ -464,31 +464,58 @@ typedef enum ir_graph_properties_t { ...@@ -464,31 +464,58 @@ typedef enum ir_graph_properties_t {
IR_GRAPH_PROPERTY_NO_CRITICAL_EDGES = 1U << 0, IR_GRAPH_PROPERTY_NO_CRITICAL_EDGES = 1U << 0,
/** graph contains no Bad nodes */ /** graph contains no Bad nodes */
IR_GRAPH_PROPERTY_NO_BADS = 1U << 1, IR_GRAPH_PROPERTY_NO_BADS = 1U << 1,
/** No tuple nodes exist in the graph */
IR_GRAPH_PROPERTY_NO_TUPLES = 1U << 2,
/** /**
* there exists no (obviously) unreachable code in the graph. * there exists no (obviously) unreachable code in the graph.
* Unreachable in this context is code that you can't reach by following * Unreachable in this context is code that you can't reach by following
* execution flow from the start block. * execution flow from the start block.
*/ */
IR_GRAPH_PROPERTY_NO_UNREACHABLE_CODE = 1U << 2, IR_GRAPH_PROPERTY_NO_UNREACHABLE_CODE = 1U << 3,
/** graph contains at most one return */ /** graph contains at most one return */
IR_GRAPH_PROPERTY_ONE_RETURN = 1U << 3, IR_GRAPH_PROPERTY_ONE_RETURN = 1U << 4,
/** dominance information about the graph is valid */ /** dominance information about the graph is valid */
IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE = 1U << 4, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE = 1U << 5,
/** postdominance information about the graph is valid */ /** postdominance information about the graph is valid */
IR_GRAPH_PROPERTY_CONSISTENT_POSTDOMINANCE = 1U << 5, IR_GRAPH_PROPERTY_CONSISTENT_POSTDOMINANCE = 1U << 6,
/** /**
* out edges (=iredges) are enable and there is no dead code that can be * out edges (=iredges) are enable and there is no dead code that can be
* reached by following them * reached by following them
*/ */
IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES = 1U << 6, IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES = 1U << 7,
/** outs (irouts) are computed and up to date */ /** outs (irouts) are computed and up to date */
IR_GRAPH_PROPERTY_CONSISTENT_OUTS = 1U << 7, IR_GRAPH_PROPERTY_CONSISTENT_OUTS = 1U << 8,
/** loopinfo is computed and up to date */ /** loopinfo is computed and up to date */
IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO = 1U << 8, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO = 1U << 9,
/** entity usage information is computed and up to date */ /** entity usage information is computed and up to date */
IR_GRAPH_PROPERTY_CONSISTENT_ENTITY_USAGE = 1U << 9, IR_GRAPH_PROPERTY_CONSISTENT_ENTITY_USAGE = 1U << 10,
/** graph contains as many returns as possible */ /** graph contains as many returns as possible */
IR_GRAPH_PROPERTY_MANY_RETURNS = 1U << 10, IR_GRAPH_PROPERTY_MANY_RETURNS = 1U << 11,
/**
* List of all graph properties that are only affected byt control flow
* changes.
*/
IR_GRAPH_PROPERTIES_CONTROL_FLOW =
IR_GRAPH_PROPERTY_NO_CRITICAL_EDGES
| IR_GRAPH_PROPERTY_ONE_RETURN
| IR_GRAPH_PROPERTY_NO_UNREACHABLE_CODE
| IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO
| IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE
| IR_GRAPH_PROPERTY_CONSISTENT_POSTDOMINANCE,
/**
* List of all graph properties.
*/
IR_GRAPH_PROPERTIES_ALL =
IR_GRAPH_PROPERTIES_CONTROL_FLOW
| IR_GRAPH_PROPERTY_NO_BADS
| IR_GRAPH_PROPERTY_NO_TUPLES
| IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES
| IR_GRAPH_PROPERTY_CONSISTENT_OUTS
| IR_GRAPH_PROPERTY_CONSISTENT_ENTITY_USAGE
| IR_GRAPH_PROPERTY_MANY_RETURNS,
} ir_graph_properties_t; } ir_graph_properties_t;
ENUM_BITSET(ir_graph_properties_t) ENUM_BITSET(ir_graph_properties_t)
...@@ -520,6 +547,19 @@ FIRM_API unsigned get_irg_fp_model(const ir_graph *irg); ...@@ -520,6 +547,19 @@ FIRM_API unsigned get_irg_fp_model(const ir_graph *irg);
/** Sets a floating point model for this graph. */ /** Sets a floating point model for this graph. */
FIRM_API void set_irg_fp_model(ir_graph *irg, unsigned model); FIRM_API void set_irg_fp_model(ir_graph *irg, unsigned model);
/**
* Ensures that a graph fulfills all properties stated in @p state.
* Performs graph transformations if necessary.
*/
FIRM_API void assure_irg_properties(ir_graph *irg, ir_graph_properties_t props);
/**
* Invalidates all graph properties/analysis data except the ones specified
* in @p props.
* This should be called after a transformation phase.
*/
FIRM_API void confirm_irg_properties(ir_graph *irg, ir_graph_properties_t props);
/** /**
* Accesses custom graph data. * Accesses custom graph data.
* The data must have been registered with * The data must have been registered with
......
...@@ -285,12 +285,6 @@ FIRM_API size_t get_irp_n_asms(void); ...@@ -285,12 +285,6 @@ FIRM_API size_t get_irp_n_asms(void);
/** Returns the global asm include at position pos. */ /** Returns the global asm include at position pos. */
FIRM_API ident *get_irp_asm(size_t pos); FIRM_API ident *get_irp_asm(size_t pos);
/** Returns whether optimization dump vcg graphs */
FIRM_API int get_irp_optimization_dumps(void);
/** Enable vcg dumping of optimization */
FIRM_API void enable_irp_optimization_dumps(void);
/** @} */ /** @} */
#include "end.h" #include "end.h"
......
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
#include "debug.h" #include "debug.h"
#include "error.h" #include "error.h"
#include "irflag.h" #include "irflag.h"
#include "opt_manage.h"
/** /**
* Walker environment. * Walker environment.
...@@ -563,14 +562,16 @@ static void insert_Confirm(ir_node *node, void *data) ...@@ -563,14 +562,16 @@ static void insert_Confirm(ir_node *node, void *data)
} }
} }
/* void construct_confirms(ir_graph *irg)
* Construct Confirm nodes
*/
static ir_graph_properties_t do_construct_confirms(ir_graph *irg)
{ {
env_t env; env_t env;
FIRM_DBG_REGISTER(dbg, "firm.ana.confirm"); FIRM_DBG_REGISTER(dbg, "firm.ana.confirm");
assure_irg_properties(irg,
IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES
| IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE
| IR_GRAPH_PROPERTY_NO_CRITICAL_EDGES);
assert(get_irg_pinned(irg) == op_pin_state_pinned && assert(get_irg_pinned(irg) == op_pin_state_pinned &&
"Nodes must be placed to insert Confirms"); "Nodes must be placed to insert Confirms");
...@@ -591,20 +592,8 @@ static ir_graph_properties_t do_construct_confirms(ir_graph *irg) ...@@ -591,20 +592,8 @@ static ir_graph_properties_t do_construct_confirms(ir_graph *irg)
DB((dbg, LEVEL_1, "# Const replacements: %u\n", env.num_consts)); DB((dbg, LEVEL_1, "# Const replacements: %u\n", env.num_consts));
DB((dbg, LEVEL_1, "# node equalities : %u\n", env.num_eq)); DB((dbg, LEVEL_1, "# node equalities : %u\n", env.num_eq));
DB((dbg, LEVEL_1, "# non-null Confirms : %u\n", env.num_non_null)); DB((dbg, LEVEL_1, "# non-null Confirms : %u\n", env.num_non_null));
return 0;
}
static optdesc_t opt_confirms = {
"confirms",
IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES
| IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE
| IR_GRAPH_PROPERTY_NO_CRITICAL_EDGES,
do_construct_confirms
};
void construct_confirms(ir_graph *irg) confirm_irg_properties(irg, IR_GRAPH_PROPERTIES_CONTROL_FLOW);
{
perform_irg_optimization(irg, &opt_confirms);
} }
ir_graph_pass_t *construct_confirms_pass(const char *name) ir_graph_pass_t *construct_confirms_pass(const char *name)
...@@ -627,6 +616,7 @@ static void remove_confirm(ir_node *n, void *env) ...@@ -627,6 +616,7 @@ static void remove_confirm(ir_node *n, void *env)
void remove_confirms(ir_graph *irg) void remove_confirms(ir_graph *irg)
{ {
irg_walk_graph(irg, NULL, remove_confirm, NULL); irg_walk_graph(irg, NULL, remove_confirm, NULL);
confirm_irg_properties(irg, IR_GRAPH_PROPERTIES_CONTROL_FLOW);
} }
ir_graph_pass_t *remove_confirms_pass(const char *name) ir_graph_pass_t *remove_confirms_pass(const char *name)
......
...@@ -950,6 +950,8 @@ static void analyse_irg_entity_usage(ir_graph *irg) ...@@ -950,6 +950,8 @@ static void analyse_irg_entity_usage(ir_graph *irg)
size_t i, n; size_t i, n;
int j, k, static_link_arg; int j, k, static_link_arg;
assure_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS);
/* set initial state to not_taken, as this is the "smallest" state */ /* set initial state to not_taken, as this is the "smallest" state */
for (i = 0, n = get_class_n_members(ft); i < n; ++i) { for (i = 0, n = get_class_n_members(ft); i < n; ++i) {
ir_entity *ent = get_class_member(ft, i); ir_entity *ent = get_class_member(ft, i);
...@@ -963,8 +965,6 @@ static void analyse_irg_entity_usage(ir_graph *irg) ...@@ -963,8 +965,6 @@ static void analyse_irg_entity_usage(ir_graph *irg)
} }
} }
assure_irg_outs(irg);
irg_frame = get_irg_frame(irg); irg_frame = get_irg_frame(irg);
for (j = get_irn_n_outs(irg_frame) - 1; j >= 0; --j) { for (j = get_irn_n_outs(irg_frame) - 1; j >= 0; --j) {
...@@ -1021,7 +1021,6 @@ static void analyse_irg_entity_usage(ir_graph *irg) ...@@ -1021,7 +1021,6 @@ static void analyse_irg_entity_usage(ir_graph *irg)
} }
} }
/* now computed */ /* now computed */
add_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_ENTITY_USAGE); add_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_ENTITY_USAGE);
} }
......
...@@ -631,6 +631,7 @@ void edges_deactivate_kind(ir_graph *irg, ir_edge_kind_t kind) ...@@ -631,6 +631,7 @@ void edges_deactivate_kind(ir_graph *irg, ir_edge_kind_t kind)
ir_edgeset_destroy(&info->edges); ir_edgeset_destroy(&info->edges);
info->allocated = 0; info->allocated = 0;
} }
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES);
} }
int (edges_activated_kind)(const ir_graph *irg, ir_edge_kind_t kind) int (edges_activated_kind)(const ir_graph *irg, ir_edge_kind_t kind)
...@@ -917,6 +918,7 @@ void assure_edges(ir_graph *irg) ...@@ -917,6 +918,7 @@ void assure_edges(ir_graph *irg)
{ {
assure_edges_kind(irg, EDGE_KIND_BLOCK); assure_edges_kind(irg, EDGE_KIND_BLOCK);
assure_edges_kind(irg, EDGE_KIND_NORMAL); assure_edges_kind(irg, EDGE_KIND_NORMAL);
add_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES);
} }
void assure_edges_kind(ir_graph *irg, ir_edge_kind_t kind) void assure_edges_kind(ir_graph *irg, ir_edge_kind_t kind)
......
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
#include "iredges_t.h" #include "iredges_t.h"
#include "type_t.h" #include "type_t.h"
#include "irmemory.h" #include "irmemory.h"
#include "iroptimize.h"
#include "irgopt.h"
#define INITIAL_IDX_IRN_MAP_SIZE 1024 #define INITIAL_IDX_IRN_MAP_SIZE 1024
...@@ -797,3 +799,43 @@ int (irg_has_properties)(const ir_graph *irg, ir_graph_properties_t props) ...@@ -797,3 +799,43 @@ int (irg_has_properties)(const ir_graph *irg, ir_graph_properties_t props)
{ {
return irg_has_properties_(irg, props); return irg_has_properties_(irg, props);
} }
typedef void (*assure_property_func)(ir_graph *irg);
void assure_irg_properties(ir_graph *irg, ir_graph_properties_t props)
{
static struct {
ir_graph_properties_t property;
assure_property_func func;
} property_functions[] = {
{ IR_GRAPH_PROPERTY_ONE_RETURN, normalize_one_return },
{ IR_GRAPH_PROPERTY_MANY_RETURNS, normalize_n_returns },
{ IR_GRAPH_PROPERTY_NO_CRITICAL_EDGES, remove_critical_cf_edges },
{ IR_GRAPH_PROPERTY_NO_UNREACHABLE_CODE, remove_unreachable_code },
{ IR_GRAPH_PROPERTY_NO_BADS, remove_bads },
{ IR_GRAPH_PROPERTY_NO_TUPLES, remove_tuples },
{ IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE, assure_doms },
{ IR_GRAPH_PROPERTY_CONSISTENT_POSTDOMINANCE, assure_postdoms },
{ IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES, assure_edges },
{ IR_GRAPH_PROPERTY_CONSISTENT_OUTS, assure_irg_outs },
{ IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO, assure_loopinfo },
{ IR_GRAPH_PROPERTY_CONSISTENT_ENTITY_USAGE, assure_irg_entity_usage_computed },
};
size_t i;
for (i = 0; i < ARRAY_SIZE(property_functions); ++i) {
ir_graph_properties_t missing = props & ~irg->properties;
if (missing & property_functions[i].property)
property_functions[i].func(irg);
}
assert((props & ~irg->properties) == IR_GRAPH_PROPERTIES_NONE);
}
void confirm_irg_properties(ir_graph *irg, ir_graph_properties_t props)
{
clear_irg_properties(irg, ~props);
if (! (props & IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES))
edges_deactivate(irg);
if (! (props & IR_GRAPH_PROPERTY_CONSISTENT_OUTS)
&& (irg->properties & IR_GRAPH_PROPERTY_CONSISTENT_OUTS))
free_irg_outs(irg);
}
...@@ -398,16 +398,6 @@ ident *get_irp_asm(size_t pos) ...@@ -398,16 +398,6 @@ ident *get_irp_asm(size_t pos)
return irp->global_asms[pos]; return irp->global_asms[pos];
} }
int (get_irp_optimization_dumps)(void)
{
return get_irp_optimization_dumps_();
}
void (enable_irp_optimization_dumps)(void)
{
enable_irp_optimization_dumps_();
}
#ifndef NDEBUG #ifndef NDEBUG
void irp_reserve_resources(ir_prog *irp, irp_resources_t resources) void irp_reserve_resources(ir_prog *irp, irp_resources_t resources)
{ {
......
...@@ -103,20 +103,6 @@ static inline ir_label_t get_irp_next_label_nr_(void) ...@@ -103,20 +103,6 @@ static inline ir_label_t get_irp_next_label_nr_(void)
return ++irp->last_label_nr; return ++irp->last_label_nr;
} }
/** Whether optimizations should dump irgs */
static inline int get_irp_optimization_dumps_(void)
{
assert(irp);
return irp->optimization_dumps;
}
/** Set optimizations to dump irgs */
static inline void enable_irp_optimization_dumps_(void)
{
assert(irp);
irp->optimization_dumps = 1;
}
void set_irp_ip_outedges(ir_node ** ip_outedges); void set_irp_ip_outedges(ir_node ** ip_outedges);
ir_node** get_irp_ip_outedges(void); ir_node** get_irp_ip_outedges(void);
...@@ -143,7 +129,5 @@ void remove_irp_type(ir_type *typ); ...@@ -143,7 +129,5 @@ void remove_irp_type(ir_type *typ);
#define get_glob_type() get_glob_type_() #define get_glob_type() get_glob_type_()
#define get_tls_type() get_tls_type_() #define get_tls_type() get_tls_type_()
#define get_irp_next_label_nr() get_irp_next_label_nr_() #define get_irp_next_label_nr() get_irp_next_label_nr_()
#define get_irp_optimization_dumps() get_irp_optimization_dumps_()
#define enable_irp_optimization_dumps() enable_irp_optimization_dumps_()
#endif #endif
...@@ -652,7 +652,6 @@ struct ir_prog { ...@@ -652,7 +652,6 @@ struct ir_prog {
size_t max_irg_idx; /**< highest unused irg index */ size_t max_irg_idx; /**< highest unused irg index */
long max_node_nr; /**< to generate unique numbers for nodes. */ long max_node_nr; /**< to generate unique numbers for nodes. */
unsigned dump_nr; /**< number of program info dumps */ unsigned dump_nr; /**< number of program info dumps */
unsigned optimization_dumps :1; /**< dump irg on each optimization */
#ifndef NDEBUG #ifndef NDEBUG
irp_resources_t reserved_resources; /**< Bitset for tracking used global resources. */ irp_resources_t reserved_resources; /**< Bitset for tracking used global resources. */
#endif #endif
......
...@@ -146,4 +146,5 @@ void remove_bads(ir_graph *irg) ...@@ -146,4 +146,5 @@ void remove_bads(ir_graph *irg)
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS); clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS);
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE); clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE);
} }
add_irg_properties(irg, IR_GRAPH_PROPERTY_NO_BADS);
} }
...@@ -57,4 +57,5 @@ static void exchange_tuple_projs(ir_node *node, void *env) ...@@ -57,4 +57,5 @@ static void exchange_tuple_projs(ir_node *node, void *env)
void remove_tuples(ir_graph *irg) void remove_tuples(ir_graph *irg)
{ {
irg_walk_graph(irg, exchange_tuple_projs, NULL, NULL); irg_walk_graph(irg, exchange_tuple_projs, NULL, NULL);
add_irg_properties(irg, IR_GRAPH_PROPERTY_NO_TUPLES);
} }
...@@ -117,17 +117,16 @@ void remove_unreachable_code(ir_graph *irg) ...@@ -117,17 +117,16 @@ void remove_unreachable_code(ir_graph *irg)
{ {
bool changed = false; bool changed = false;
assure_doms(irg); assure_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE);
irg_walk_graph(irg, unreachable_to_bad, NULL, &changed); irg_walk_graph(irg, unreachable_to_bad, NULL, &changed);
remove_unreachable_keeps(irg); remove_unreachable_keeps(irg);
if (changed) { confirm_irg_properties(irg, changed
edges_deactivate(irg); ? IR_GRAPH_PROPERTY_NO_CRITICAL_EDGES
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS | IR_GRAPH_PROPERTY_NO_TUPLES
| IR_GRAPH_PROPERTY_NO_BADS | IR_GRAPH_PROPERTY_ONE_RETURN
| IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES | IR_GRAPH_PROPERTY_MANY_RETURNS
| IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO); : IR_GRAPH_PROPERTIES_ALL);
}
add_irg_properties(irg, IR_GRAPH_PROPERTY_NO_UNREACHABLE_CODE); add_irg_properties(irg, IR_GRAPH_PROPERTY_NO_UNREACHABLE_CODE);
} }
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include "tv.h" #include "tv.h"
#include "irpass.h" #include "irpass.h"
#include "debug.h" #include "debug.h"
#include "opt_manage.h"
/** Describes a pair of relative conditions lo < hi, lo rel_lo x, hi rel_hi x */ /** Describes a pair of relative conditions lo < hi, lo rel_lo x, hi rel_hi x */
typedef struct cond_pair { typedef struct cond_pair {
...@@ -716,10 +715,9 @@ restart: ...@@ -716,10 +715,9 @@ restart:
} }
} }
static ir_graph_properties_t do_simplify_bool(ir_graph *const irg) void opt_bool(ir_graph *const irg)
{ {
bool_opt_env_t env; bool_opt_env_t env;
ir_graph_properties_t res = 0;
/* register a debug mask */ /* register a debug mask */
FIRM_DBG_REGISTER(dbg, "firm.opt.bool"); FIRM_DBG_REGISTER(dbg, "firm.opt.bool");
...@@ -729,30 +727,14 @@ static ir_graph_properties_t do_simplify_bool(ir_graph *const irg) ...@@ -729,30 +727,14 @@ static ir_graph_properties_t do_simplify_bool(ir_graph *const irg)
/* optimize simple Andb and Orb cases */ /* optimize simple Andb and Orb cases */
irg_walk_graph(irg, NULL, bool_walk, &env); irg_walk_graph(irg, NULL, bool_walk, &env);
ir_reserve_resources(irg, IR_RESOURCE_BLOCK_MARK | IR_RESOURCE_PHI_LIST);
/* now more complicated cases: find control flow And/Or and optimize. */ /* now more complicated cases: find control flow And/Or and optimize. */
ir_reserve_resources(irg, IR_RESOURCE_BLOCK_MARK | IR_RESOURCE_PHI_LIST);
irg_walk_graph(irg, clear_block_infos, collect_phis, NULL); irg_walk_graph(irg, clear_block_infos, collect_phis, NULL);
irg_block_walk_graph(irg, NULL, find_cf_and_or_walker, &env); irg_block_walk_graph(irg, NULL, find_cf_and_or_walker, &env);
if (! env.changed) {
res |= IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE;
}
ir_free_resources(irg, IR_RESOURCE_BLOCK_MARK | IR_RESOURCE_PHI_LIST); ir_free_resources(irg, IR_RESOURCE_BLOCK_MARK | IR_RESOURCE_PHI_LIST);
return res; confirm_irg_properties(irg,
} env.changed ? IR_GRAPH_PROPERTIES_NONE : IR_GRAPH_PROPERTIES_ALL);
static optdesc_t opt_simplify_bool = {
"bool-simplification",
IR_GRAPH_PROPERTY_ONE_RETURN, /* works better with one return block only */
do_simplify_bool,
};
void opt_bool(ir_graph *irg)
{
perform_irg_optimization(irg, &opt_simplify_bool);
} }
/* Creates an ir_graph pass for opt_bool. */ /* Creates an ir_graph pass for opt_bool. */
......
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
#include "irdump.h" #include "irdump.h"
#include "irverify.h" #include "irverify.h"
#include "iredges.h" #include "iredges.h"
#include "opt_manage.h"
#include "array_t.h" #include "array_t.h"
...@@ -809,12 +808,13 @@ static void cfgopt_ignoring_phis(ir_graph *irg) ...@@ -809,12 +808,13 @@ static void cfgopt_ignoring_phis(ir_graph *irg)
irg_block_walk_graph(irg, NULL, optimize_ifs, &env); irg_block_walk_graph(irg, NULL, optimize_ifs, &env);
if (env.changed) { if (env.changed) {
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE); confirm_irg_properties(irg, IR_GRAPH_PROPERTIES_NONE);
/* clear block info, because it must be recomputed */ /* clear block info, because it must be recomputed */
irg_block_walk_graph(irg, clear_block_info, NULL, &env.block_infos); irg_block_walk_graph(irg, clear_block_info, NULL, &env.block_infos);
/* Removing blocks and Conds might enable more optimizations */ /* Removing blocks and Conds might enable more optimizations */
continue; continue;
} else { } else {
confirm_irg_properties(irg, IR_GRAPH_PROPERTIES_ALL);
break; break;
} }
} }
...@@ -823,7 +823,7 @@ static void cfgopt_ignoring_phis(ir_graph *irg) ...@@ -823,7 +823,7 @@ static void cfgopt_ignoring_phis(ir_graph *irg)
} }
/* Optimizations of the control flow that also require changes of Phi nodes. */ /* Optimizations of the control flow that also require changes of Phi nodes. */
static ir_graph_properties_t do_cfopt(ir_graph *irg) void optimize_cf(ir_graph *irg)
{ {
int i, j, n; int i, j, n;
ir_node **in = NULL; ir_node **in = NULL;
...@@ -840,7 +840,7 @@ static ir_graph_properties_t do_cfopt(ir_graph *irg) ...@@ -840,7 +840,7 @@ static ir_graph_properties_t do_cfopt(ir_graph *irg)
assert(get_irg_pinned(irg) != op_pin_state_floats && assert(get_irg_pinned(irg) != op_pin_state_floats &&
"Control flow optimization need a pinned graph"); "Control flow optimization need a pinned graph");
edges_deactivate(irg); assure_irg_properties(irg, IR_GRAPH_PROPERTY_NO_UNREACHABLE_CODE);
/* First the "simple" optimizations, which do not touch Phis */ /* First the "simple" optimizations, which do not touch Phis */
cfgopt_ignoring_phis(irg); cfgopt_ignoring_phis(irg);
...@@ -866,7 +866,7 @@ static ir_graph_properties_t do_cfopt(ir_graph *irg) ...@@ -866,7 +866,7 @@ static ir_graph_properties_t do_cfopt(ir_graph *irg)
* It walks only over block nodes and adapts these and the Phi nodes in * It walks only over block nodes and adapts these and the Phi nodes in
* these blocks, which it finds in a linked list computed before. * these blocks, which it finds in a linked list computed before.
*/ */
assure_doms(irg); assure_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE);
irg_block_walk_graph(irg, optimize_blocks, merge_blocks, &env); irg_block_walk_graph(irg, optimize_blocks, merge_blocks, &env);
new_end = optimize_in_place(end); new_end = optimize_in_place(end);
...@@ -915,18 +915,8 @@ static ir_graph_properties_t do_cfopt(ir_graph *irg) ...@@ -915,18 +915,8 @@ static ir_graph_properties_t do_cfopt(ir_graph *irg)
} }
} }
return 0; confirm_irg_properties(irg,
} env.changed ? IR_GRAPH_PROPERTIES_NONE : IR_GRAPH_PROPERTIES_ALL);
static optdesc_t opt_cf = {
"control-flow",
IR_GRAPH_PROPERTY_NO_UNREACHABLE_CODE,
do_cfopt,
};