------- Comment #12 from pinskia at gcc dot gnu dot org 2007-03-18 17:36 ------- This patch works for me for this testcase, I have not tested it. basicially the "The only case we did not replace all uses" is false and if we always return false there, we don't prop on the right hand side until later and this makes us prop on the rhs early on. Oh and also changes so we skip all references instead of just COMPONENT_REF and ARRAY_REF so we can look into REAL_EXPR<INDIRECT_REF<>>, etc.
Index: tree-ssa-forwprop.c =================================================================== --- tree-ssa-forwprop.c (revision 123034) +++ tree-ssa-forwprop.c (working copy) @@ -680,7 +680,7 @@ /* Strip away any outer COMPONENT_REF/ARRAY_REF nodes from the LHS. ADDR_EXPR will not appear on the LHS. */ lhs = GIMPLE_STMT_OPERAND (use_stmt, 0); - while (TREE_CODE (lhs) == COMPONENT_REF || TREE_CODE (lhs) == ARRAY_REF) + while (handled_component_p (lhs)) lhs = TREE_OPERAND (lhs, 0); rhs = GIMPLE_STMT_OPERAND (use_stmt, 1); @@ -694,17 +694,13 @@ TREE_OPERAND (lhs, 0) = unshare_expr (def_rhs); fold_stmt_inplace (use_stmt); tidy_after_forward_propagate_addr (use_stmt); - - /* The only case we did not replace all uses this way is if the - use statement is of the form *name = name. */ - return rhs != name; } /* Trivial case. The use statement could be a trivial copy or a useless conversion. Recurse to the uses of the lhs as copyprop does not copy through differen variant pointers and FRE does not catch all useless conversions. */ - else if ((TREE_CODE (lhs) == SSA_NAME + if ((TREE_CODE (lhs) == SSA_NAME && rhs == name) || ((TREE_CODE (rhs) == NOP_EXPR || TREE_CODE (rhs) == CONVERT_EXPR) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31254