summaryrefslogtreecommitdiffhomepage
path: root/ir/ana
diff options
context:
space:
mode:
authorAndreas Fried <andreas.fried@kit.edu>2018-07-05 17:14:53 +0200
committerAndreas Fried <andreas.fried@kit.edu>2018-07-05 17:29:57 +0200
commit844580d5cc63d97be2ab4d0b1f3763456060b82e (patch)
tree6b5c724b8e3af562648ad0e7e0a0abd7b558dd35 /ir/ana
parenta71e45e283e90a4376b9fe33171b784f85ffa230 (diff)
Add construct_confirms_only function.
This function only inserts Confirms into a graph without performing any further optimizations.
Diffstat (limited to 'ir/ana')
-rw-r--r--ir/ana/irconsconfirm.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/ir/ana/irconsconfirm.c b/ir/ana/irconsconfirm.c
index 01b56d5..6f7ecc7 100644
--- a/ir/ana/irconsconfirm.c
+++ b/ir/ana/irconsconfirm.c
@@ -28,6 +28,7 @@
* Walker environment.
*/
typedef struct env_t {
+ bool optimize; /**< Do other optimizations as well as inserting Confirms. */
unsigned num_confirms; /**< Number of inserted Confirm nodes. */
unsigned num_consts; /**< Number of constants placed. */
unsigned num_eq; /**< Number of equalities placed. */
@@ -88,6 +89,10 @@ static ir_node *get_case_value(ir_node *switchn, unsigned pn)
*/
static void handle_case(ir_node *block, ir_node *switchn, unsigned pn, env_t *env)
{
+ if (!env->optimize) {
+ return;
+ }
+
ir_node *c = NULL;
ir_node *selector = get_Switch_selector(switchn);
@@ -130,6 +135,10 @@ static void handle_case(ir_node *block, ir_node *switchn, unsigned pn, env_t *en
*/
static void handle_modeb(ir_node *block, ir_node *selector, pn_Cond pnc, env_t *env)
{
+ if (!env->optimize) {
+ return;
+ }
+
ir_node *other_blk = NULL;
ir_node *con = NULL;
ir_node *c_b = NULL;
@@ -270,7 +279,7 @@ static void handle_if(ir_node *block, ir_node *cmp, ir_relation rel, env_t *env)
* First case: both values are identical.
* replace the left one by the right (potentially const) one.
*/
- if (rel == ir_relation_equal) {
+ if (env->optimize && rel == ir_relation_equal) {
ir_node *cond_block = get_Block_cfgpred_block(block, 0);
foreach_out_edge_safe(left, edge) {
ir_node *user = get_edge_src_irn(edge);
@@ -515,7 +524,7 @@ static void insert_Confirm(ir_node *node, void *data)
}
}
-void construct_confirms(ir_graph *irg)
+static void do_construct_confirms(ir_graph *irg, bool optimize)
{
FIRM_DBG_REGISTER(dbg, "firm.ana.confirm");
@@ -528,6 +537,7 @@ void construct_confirms(ir_graph *irg)
assert(get_irg_pinned(irg) == op_pin_state_pinned);
env_t env;
+ env.optimize = optimize;
env.num_confirms = 0;
env.num_consts = 0;
env.num_eq = 0;
@@ -549,6 +559,16 @@ void construct_confirms(ir_graph *irg)
confirm_irg_properties(irg, IR_GRAPH_PROPERTIES_CONTROL_FLOW);
}
+void construct_confirms(ir_graph *irg)
+{
+ do_construct_confirms(irg, true);
+}
+
+void construct_confirms_only(ir_graph *irg)
+{
+ do_construct_confirms(irg, false);
+}
+
static void remove_confirm(ir_node *n, void *env)
{
(void)env;