diff options
author | Sebastian Pop <sebastian.pop@amd.com> | 2009-08-12 14:32:31 +0000 |
---|---|---|
committer | Sebastian Pop <spop@gcc.gnu.org> | 2009-08-12 14:32:31 +0000 |
commit | 30de16328a546dd06011235d86ef573dc2ffba6e (patch) | |
tree | 283fef24a62d6d0e162a392a4ac2a0c78b3137b3 /gcc/sese.c | |
parent | 8c31ebfa3a8b00106ebad9658b526d41aaa5cf19 (diff) | |
download | gcc-30de16328a546dd06011235d86ef573dc2ffba6e.zip gcc-30de16328a546dd06011235d86ef573dc2ffba6e.tar.gz gcc-30de16328a546dd06011235d86ef573dc2ffba6e.tar.bz2 |
Prepare expressions to be good phi arguments.
2009-08-11 Sebastian Pop <sebastian.pop@amd.com>
PR middle-end/40980
* sese.c (convert_for_phi_arg): New.
(add_guard_exit_phis): Use convert_for_phi_arg.
* testsuite/gfortran.dg/graphite/id-17.f: New.
From-SVN: r150694
Diffstat (limited to 'gcc/sese.c')
-rw-r--r-- | gcc/sese.c | 50 |
1 files changed, 31 insertions, 19 deletions
@@ -1085,6 +1085,31 @@ default_before_guard (htab_t before_guard, tree old_name) return res; } +/* Prepares EXPR to be a good phi argument when the phi result is + RES. Insert needed statements on edge E. */ + +static tree +convert_for_phi_arg (tree expr, tree res, edge e) +{ + tree type = TREE_TYPE (res); + + if (TREE_TYPE (expr) != type) + expr = fold_convert (type, expr); + + if (TREE_CODE (expr) != SSA_NAME + && !is_gimple_min_invariant (expr)) + { + tree var = create_tmp_var (type, "var"); + gimple_seq stmts; + + expr = build2 (MODIFY_EXPR, type, var, expr); + expr = force_gimple_operand (expr, &stmts, true, NULL); + gsi_insert_seq_on_edge_immediate (e, stmts); + } + + return expr; +} + /* Helper function for htab_traverse in insert_guard_phis. */ static int @@ -1095,33 +1120,20 @@ add_guard_exit_phis (void **slot, void *s) basic_block bb = i->bb; edge true_edge = i->true_edge; edge false_edge = i->false_edge; + tree res = entry->old_name; tree name1 = entry->expr; - tree name2 = default_before_guard (i->before_guard, entry->old_name); + tree name2 = default_before_guard (i->before_guard, res); gimple phi; - tree res; - gimple_seq stmts; /* Nothing to be merged if the name before the guard is the same as the one after. */ if (name1 == name2) return 1; - if (TREE_TYPE (name1) != TREE_TYPE (name2)) - name1 = fold_convert (TREE_TYPE (name2), name1); + name1 = convert_for_phi_arg (name1, res, true_edge); + name2 = convert_for_phi_arg (name2, res, false_edge); - if (TREE_CODE (name1) != SSA_NAME - && (TREE_CODE (name2) != SSA_NAME - || is_gimple_reg (name2))) - { - tree type = TREE_TYPE (name2); - tree var = create_tmp_var (type, "var"); - - name1 = build2 (MODIFY_EXPR, type, var, name1); - name1 = force_gimple_operand (name1, &stmts, true, NULL); - gsi_insert_seq_on_edge_immediate (true_edge, stmts); - } - - phi = create_phi_node (entry->old_name, bb); + phi = create_phi_node (res, bb); res = create_new_def_for (gimple_phi_result (phi), phi, gimple_phi_result_ptr (phi)); @@ -1136,7 +1148,7 @@ add_guard_exit_phis (void **slot, void *s) /* Iterate over RENAME_MAP and get tuples of the form (OLD, NAME1). If there is a correspondent tuple (OLD, NAME2) in BEFORE_GUARD, with NAME1 different than NAME2, then insert in BB the phi node: - + | RES = phi (NAME1 (on TRUE_EDGE), NAME2 (on FALSE_EDGE))" if there is no tuple for OLD in BEFORE_GUARD, insert |