This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] tree-ssa-ccp.c: Remove code that produces non-gimple mininvariant.


Hi,

Attached is a patch to remove code that produces non-gimple min
invariant.

Note that the sole user of ccp_fold is evaluate_stmt, and that
evaluate_stmt basically does

  tree simplified = ccp_fold (stmt);
  if (simplified && is_gimple_min_invariant (simplified))
    /* Set the lattice value to CONSTANT.  */
    ;
  else
    /* Set the lattice value to either UNDEFINED or VARYING.  */
    ;

That is, if ccp_fold returns something that does not satisfy
is_gimple_min_invariant, then evaluate_stmt throws away the return
value.  In other words, ccp_fold is producing garbage.

The patch solves this problem by removing code that produces garbage.

Tested on i686-pc-linux-gnu.  OK to apply?

Kazu Hirata

2005-05-28  Kazu Hirata  <kazu@cs.umass.edu>

	* tree-ssa-ccp.c (ccp_fold): Remove code that produces
	non-gimple min minvariant.

Index: tree-ssa-ccp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-ccp.c,v
retrieving revision 2.73
diff -u -d -p -r2.73 tree-ssa-ccp.c
--- tree-ssa-ccp.c	27 May 2005 16:31:20 -0000	2.73
+++ tree-ssa-ccp.c	27 May 2005 16:40:03 -0000
@@ -855,21 +855,6 @@ ccp_fold (tree stmt)
 	 use this expression.  */
       if (retval && ! is_gimple_min_invariant (retval))
 	return NULL;
-
-      /* If we could not fold the expression, but the arguments are all
-         constants and gimple values, then build and return the new
-	 expression. 
-
-	 In some cases the new expression is still something we can
-	 use as a replacement for an argument.  This happens with
-	 NOP conversions of types for example.
-
-	 In other cases the new expression can not be used as a
-	 replacement for an argument (as it would create non-gimple
-	 code).  But the new expression can still be used to derive
-	 other constants.  */
-      if (! retval && is_gimple_min_invariant (op0))
-	return build1 (code, TREE_TYPE (rhs), op0);
     }
 
   /* Binary and comparison operators.  We know one or both of the
@@ -906,23 +891,6 @@ ccp_fold (tree stmt)
 	 use this expression.  */
       if (retval && ! is_gimple_min_invariant (retval))
 	return NULL;
-      
-      /* If we could not fold the expression, but the arguments are all
-         constants and gimple values, then build and return the new
-	 expression. 
-
-	 In some cases the new expression is still something we can
-	 use as a replacement for an argument.  This happens with
-	 NOP conversions of types for example.
-
-	 In other cases the new expression can not be used as a
-	 replacement for an argument (as it would create non-gimple
-	 code).  But the new expression can still be used to derive
-	 other constants.  */
-      if (! retval
-	  && is_gimple_min_invariant (op0)
-	  && is_gimple_min_invariant (op1))
-	return build (code, TREE_TYPE (rhs), op0, op1);
     }
 
   /* We may be able to fold away calls to builtin functions if their


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]