diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-01-16 12:36:38 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-01-16 12:36:38 +0000 |
commit | e216a9a3bc6ad3296d31f457da83c50bac029edc (patch) | |
tree | 6751b799774ee191126a39fcea165f308b606f08 /gcc/sese.c | |
parent | 113c4c5ebda13008acb3e98d10d449aceb80a034 (diff) | |
download | gcc-e216a9a3bc6ad3296d31f457da83c50bac029edc.tar.gz |
2010-01-16 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 155960
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@155962 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/sese.c')
-rw-r--r-- | gcc/sese.c | 97 |
1 files changed, 94 insertions, 3 deletions
diff --git a/gcc/sese.c b/gcc/sese.c index 50ac698ec0f..f959bdb269e 100644 --- a/gcc/sese.c +++ b/gcc/sese.c @@ -486,7 +486,7 @@ sese_adjust_vphi (sese region, gimple phi, edge true_e) } } -/* Returns the name associated to OLD_NAME in MAP. */ +/* Returns the expression associated to OLD_NAME in MAP. */ static tree get_rename (htab_t map, tree old_name) @@ -503,7 +503,7 @@ get_rename (htab_t map, tree old_name) return old_name; } -/* Register in MAP the rename tuple (old_name, expr). */ +/* Register in MAP the rename tuple (OLD_NAME, EXPR). */ void set_rename (htab_t map, tree old_name, tree expr) @@ -526,6 +526,67 @@ set_rename (htab_t map, tree old_name, tree expr) *slot = new_rename_map_elt (old_name, expr); } +static void rename_variables_in_expr (htab_t, tree); + +/* Renames the operand OP of expression T following the tuples + (OLD_NAME, EXPR) in RENAME_MAP. */ + +static void +rename_variables_in_operand (htab_t rename_map, tree t, int op) +{ + tree operand = TREE_OPERAND (t, op); + + if (TREE_CODE (operand) == SSA_NAME) + { + tree new_name = get_rename (rename_map, operand); + + if (new_name != operand) + TREE_OPERAND (t, op) = new_name; + } + else + rename_variables_in_expr (rename_map, operand); +} + +/* Renames the expression T following the tuples (OLD_NAME, EXPR) in + RENAME_MAP. */ + +static void +rename_variables_in_expr (htab_t rename_map, tree t) +{ + if (!t) + return; + + switch (TREE_CODE_LENGTH (TREE_CODE (t))) + { + case 3: + rename_variables_in_operand (rename_map, t, 2); + + case 2: + rename_variables_in_operand (rename_map, t, 1); + + case 1: + rename_variables_in_operand (rename_map, t, 0); + + default: + return; + } +} + +/* Renames all the loop->nb_iterations expressions following the + tuples (OLD_NAME, EXPR) in RENAME_MAP. */ + +void +rename_nb_iterations (htab_t rename_map) +{ + loop_iterator li; + struct loop *loop; + + FOR_EACH_LOOP (li, loop, 0) + { + rename_variables_in_expr (rename_map, loop->nb_iterations); + } +} + /* Adjusts the phi nodes in the block BB for variables defined in SCOP_REGION and used outside the SCOP_REGION. The code generation moves SCOP_REGION in the else clause of an "if (1)" and generates @@ -550,8 +611,9 @@ sese_adjust_liveout_phis (sese region, htab_t rename_map, basic_block bb, unsigned i; unsigned false_i = 0; gimple phi = gsi_stmt (si); + tree res = gimple_phi_result (phi); - if (!is_gimple_reg (PHI_RESULT (phi))) + if (!is_gimple_reg (res)) { sese_adjust_vphi (region, phi, true_e); continue; @@ -585,6 +647,7 @@ sese_adjust_liveout_phis (sese region, htab_t rename_map, basic_block bb, } SET_PHI_ARG_DEF (phi, i, expr); + set_rename (rename_map, old_name, res); } } } @@ -1495,6 +1558,34 @@ move_sese_in_condition (sese region) return if_region; } +/* Replaces the condition of the IF_REGION with CONDITION: + | if (CONDITION) + | true_region; + | else + | false_region; +*/ + +void +set_ifsese_condition (ifsese if_region, tree condition) +{ + sese region = if_region->region; + edge entry = region->entry; + basic_block bb = entry->dest; + gimple last = last_stmt (bb); + gimple_stmt_iterator gsi = gsi_last_bb (bb); + gimple cond_stmt; + + gcc_assert (gimple_code (last) == GIMPLE_COND); + + gsi_remove (&gsi, true); + gsi = gsi_last_bb (bb); + condition = force_gimple_operand_gsi (&gsi, condition, true, NULL, + false, GSI_NEW_STMT); + cond_stmt = gimple_build_cond_from_tree (condition, NULL_TREE, NULL_TREE); + gsi = gsi_last_bb (bb); + gsi_insert_after (&gsi, cond_stmt, GSI_NEW_STMT); +} + /* Returns the scalar evolution of T in REGION. Every variable that is not defined in the REGION is considered a parameter. */ |