------- Comment #11 from pinskia at gcc dot gnu dot org 2006-11-27 08:06 ------- Here is the patch which fixes the PHI issue but I don't know if it will always fix the PRE issue but I think it will as the PRE issue is always with VOPs: Index: tree-ssa-dom.c =================================================================== --- tree-ssa-dom.c (revision 119245) +++ tree-ssa-dom.c (working copy) @@ -1700,8 +1700,10 @@ cprop_operand (tree stmt, use_operand_p depth than the propagatee. Otherwise, this may move loop variant variables outside of their loops and prevent coalescing opportunities. If the value was loop invariant, it will be hoisted - by LICM and exposed for copy propagation. */ - if (loop_depth_of_name (val) > loop_depth_of_name (op)) + by LICM and exposed for copy propagation. We don't care much about + virtual operands. */ + if (loop_depth_of_name (val) > loop_depth_of_name (op) + && is_gimple_reg (val)) return false;
/* Dump details. */ @@ -2136,12 +2138,13 @@ static void propagate_rhs_into_lhs (tree stmt, tree lhs, tree rhs, bitmap interesting_names) { /* First verify that propagation is valid and isn't going to move a - loop variant variable outside its loop. */ + loop variant variable outside its loop except for vops. */ if (! SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs) && (TREE_CODE (rhs) != SSA_NAME || ! SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs)) && may_propagate_copy (lhs, rhs) - && loop_depth_of_name (lhs) >= loop_depth_of_name (rhs)) + && (loop_depth_of_name (lhs) > loop_depth_of_name (rhs) + || !is_gimple_reg (lhs))) { use_operand_p use_p; imm_use_iterator iter; Index: tree-ssa-copy.c =================================================================== --- tree-ssa-copy.c (revision 119245) +++ tree-ssa-copy.c (working copy) @@ -801,8 +801,10 @@ copy_prop_visit_phi_node (tree phi) Otherwise, this may move loop variant variables outside of their loops and prevent coalescing opportunities. If the value was loop invariant, it will be hoisted by LICM and - exposed for copy propagation. */ - if (loop_depth_of_name (arg) > loop_depth_of_name (lhs)) + exposed for copy propagation. We don't much about virtual + operands as they don't cause any LICM to happen. */ + if (loop_depth_of_name (arg) > loop_depth_of_name (lhs) + && is_gimple_reg (arg)) { phi_val.value = lhs; break; -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29922