diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-08-13 09:29:28 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-08-13 09:29:28 +0000 |
commit | a15039218ed24acb3c64c457d2d90d5942030f41 (patch) | |
tree | 7c5e8c4bffe7ee3b7011e166aad59c25d4c19ff7 /gcc/tree-ssa-copyrename.c | |
parent | eab36a5a647a1f2e3660c86db736e7ff0190d328 (diff) | |
download | gcc-a15039218ed24acb3c64c457d2d90d5942030f41.tar.gz |
2012-08-13 Richard Guenther <rguenther@suse.de>
PR tree-optimization/54200
* tree-ssa-copyrename.c (rename_ssa_copies): Do not add
PHI results to another partition if not all PHI arguments
have the same partition.
* gcc.dg/guality/pr54200.c: New testcase.
* gcc.dg/tree-ssa/slsr-8.c: Adjust.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@190339 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-copyrename.c')
-rw-r--r-- | gcc/tree-ssa-copyrename.c | 52 |
1 files changed, 45 insertions, 7 deletions
diff --git a/gcc/tree-ssa-copyrename.c b/gcc/tree-ssa-copyrename.c index 82f8c64fe1c..387e67bce6e 100644 --- a/gcc/tree-ssa-copyrename.c +++ b/gcc/tree-ssa-copyrename.c @@ -348,15 +348,53 @@ rename_ssa_copies (void) res = gimple_phi_result (phi); /* Do not process virtual SSA_NAMES. */ - if (!is_gimple_reg (res)) + if (virtual_operand_p (res)) continue; - for (i = 0; i < gimple_phi_num_args (phi); i++) - { - tree arg = gimple_phi_arg (phi, i)->def; - if (TREE_CODE (arg) == SSA_NAME) - updated |= copy_rename_partition_coalesce (map, res, arg, debug); - } + /* Make sure to only use the same partition for an argument + as the result but never the other way around. */ + if (SSA_NAME_VAR (res) + && !DECL_IGNORED_P (SSA_NAME_VAR (res))) + for (i = 0; i < gimple_phi_num_args (phi); i++) + { + tree arg = PHI_ARG_DEF (phi, i); + if (TREE_CODE (arg) == SSA_NAME) + updated |= copy_rename_partition_coalesce (map, res, arg, + debug); + } + /* Else if all arguments are in the same partition try to merge + it with the result. */ + else + { + int all_p_same = -1; + int p = -1; + for (i = 0; i < gimple_phi_num_args (phi); i++) + { + tree arg = PHI_ARG_DEF (phi, i); + if (TREE_CODE (arg) != SSA_NAME) + { + all_p_same = 0; + break; + } + else if (all_p_same == -1) + { + p = partition_find (map->var_partition, + SSA_NAME_VERSION (arg)); + all_p_same = 1; + } + else if (all_p_same == 1 + && p != partition_find (map->var_partition, + SSA_NAME_VERSION (arg))) + { + all_p_same = 0; + break; + } + } + if (all_p_same == 1) + updated |= copy_rename_partition_coalesce (map, res, + PHI_ARG_DEF (phi, 0), + debug); + } } } |