public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [tuples] fix thinkos in forwprop
@ 2008-06-30 18:26 Aldy Hernandez
  2008-06-30 22:12 ` Richard Guenther
  0 siblings, 1 reply; 5+ messages in thread
From: Aldy Hernandez @ 2008-06-30 18:26 UTC (permalink / raw)
  To: dnovillo, gcc-patches

This fixes a handful of regressions caused by enabling forwprop.

Committed to branch.

	* tree-ssa-forwprop.c: Remove obsolete comment.
	(get_prop_source_stmt): Wrap call to gimple_assign_lhs with a
	TREE_TYPE.
	(forward_propagate_comparison): Use build2 instead of
	fold_binary.

Index: tree-ssa-forwprop.c
===================================================================
--- tree-ssa-forwprop.c	(revision 137150)
+++ tree-ssa-forwprop.c	(working copy)
@@ -40,11 +40,6 @@ along with GCC; see the file COPYING3.  
    form of tree combination.   It is hoped all of this can disappear
    when we have a generalized tree combiner.
 
-   Note carefully that after propagation the resulting statement
-   must still be a proper gimple statement.  Right now we simply
-   only perform propagations we know will result in valid gimple
-   code.  One day we'll want to generalize this code.
-
    One class of common cases we handle is forward propagating a single use
    variable into a COND_EXPR.  
 
@@ -239,7 +234,7 @@ get_prop_source_stmt (tree name, bool si
 	rhs = gimple_assign_rhs1 (def_stmt);
 	if (IS_CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt))
 	    && TREE_CODE (rhs) == SSA_NAME
-	    && POINTER_TYPE_P (gimple_assign_lhs (def_stmt))
+	    && POINTER_TYPE_P (TREE_TYPE (gimple_assign_lhs (def_stmt)))
 	    && POINTER_TYPE_P (TREE_TYPE (rhs)))
 	  name = rhs;
 	else
@@ -970,13 +965,14 @@ forward_propagate_comparison (gimple stm
       {
         enum tree_code code = gimple_assign_rhs_code (use_stmt);
         tree cst = gimple_assign_rhs2 (use_stmt);
+	tree cond;
+
+	cond = build2 (gimple_assign_rhs_code (stmt),
+		       TREE_TYPE (cst),
+		       gimple_assign_rhs1 (stmt),
+		       gimple_assign_rhs2 (stmt));
 
-        tmp = combine_cond_expr_cond (code, TREE_TYPE (lhs),
-                                      fold_binary (code,
-                                                   TREE_TYPE (cst),
-                                                   gimple_assign_rhs1 (stmt),
-                                                   gimple_assign_rhs2 (stmt)),
-                                      cst, false);
+        tmp = combine_cond_expr_cond (code, TREE_TYPE (lhs), cond, cst, false);
         if (tmp == NULL_TREE)
           return false;
       }

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-07-02 11:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-30 18:26 [tuples] fix thinkos in forwprop Aldy Hernandez
2008-06-30 22:12 ` Richard Guenther
2008-06-30 22:18   ` Aldy Hernandez
2008-06-30 22:23     ` Andrew Pinski
2008-07-02 12:24       ` Aldy Hernandez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).