+2007-05-02 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/31146
+ * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): New
+ argument, single_use_p. If we have a single use that is
+ a conversion to the definition rhs type, propagate that rhs.
+ (forward_propagate_addr_expr): Pass single_use_p argument
+ to forward_propagate_addr_expr_1.
+
2007-05-01 H.J. Lu <hongjiu.lu@intel.com>
* config/i386/i386.c (ix86_expand_sse_comi): Remove unused
be not totally successful, yet things may have been changed). */
static bool
-forward_propagate_addr_expr_1 (tree name, tree def_rhs, tree use_stmt)
+forward_propagate_addr_expr_1 (tree name, tree def_rhs, tree use_stmt,
+ bool single_use_p)
{
tree lhs, rhs, array_ref;
/* Continue propagating into the RHS. */
}
- /* Trivial case. The use statement could be a trivial copy or a
+ /* Trivial cases. 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. */
+ all useless conversions. Treat the case of a single-use name and
+ a conversion to def_rhs type separate, though. */
+ else if (TREE_CODE (lhs) == SSA_NAME
+ && (TREE_CODE (rhs) == NOP_EXPR
+ || TREE_CODE (rhs) == CONVERT_EXPR)
+ && TREE_TYPE (rhs) == TREE_TYPE (def_rhs)
+ && single_use_p)
+ {
+ GIMPLE_STMT_OPERAND (use_stmt, 1) = unshare_expr (def_rhs);
+ return true;
+ }
else if ((TREE_CODE (lhs) == SSA_NAME
&& rhs == name)
|| ((TREE_CODE (rhs) == NOP_EXPR
imm_use_iterator iter;
tree use_stmt;
bool all = true;
+ bool single_use_p = has_single_use (name);
FOR_EACH_IMM_USE_STMT (use_stmt, iter, name)
{
push_stmt_changes (&use_stmt);
- result = forward_propagate_addr_expr_1 (name, rhs, use_stmt);
+ result = forward_propagate_addr_expr_1 (name, rhs, use_stmt,
+ single_use_p);
all &= result;
pop_stmt_changes (&use_stmt);