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]

Re: [patch] tree-vrp.c: Remove has_assert_expr.


On Wed, May 04, 2005 at 10:52:13AM -0400, Kazu Hirata wrote:
> Hi,
> 
> Attached is a patch to remove has_assert_expr as it is currently a
> no-op.
> 
> AFAICT, has_assert_expr was designed to avoid insertions of redundant
> ASSERT_EXPRs.  For example, given
> 
>   p->a = 3;
>   p->b = 5;
> 
> we do not want to insert two ASSERT_EXPRs like so
> 
>   p->a = 3;
>   p = ASSERT_EXPR <p, p != 0B>;
>   p->b = 5;
>   p = ASSERT_EXPR <p, p != 0B>;
> 
> because the second is totally redundant given the first one.  However,
> it's not functioning at all.  The reason is that it always returns
> false immediately.
> 
>   if (TREE_CODE (def_stmt) != MODIFY_EXPR
>       || TREE_CODE (TREE_OPERAND (def_stmt, 1)) != ASSERT_EXPR)
>     return false;
> 
> While inserting ASSERT_EXPRs, there is no SSA_NAME that has at least
> one use and is defined by an ASERT_EXPR.  This is because ASSERT_EXPRs
> are born in VRP.  They aren't present in prior passes.
> 
> Tested on i686-pc-linux-gnu.  OK to apply?
> 
> p.s.
> I am playing with a quick-n-dirty pruning now.  Specifically, for each
> SSA_NAME, I am keeping track of a basic block where a "nonnull"
> ASSERT_EXPR is last inserted.  This cuts down the number of
> ASSERT_EXPRs significantly, about 50%.  I'll post a separate message
> about this.
> 
> Kazu Hirata
> 
> 2005-05-04  Kazu Hirata  <kazu@cs.umass.edu>
> 
> 	PR tree-optimization/pr21348
> 	* tree-vrp.c (has_assert_expr): Remove.
> 	(maybe_add_assert_expr): Don't call has_assert_expr.
> 
Sigh.  How could I miss this.  But not OK.

Better fix has_assert_expr.  This presence test will suffice for
now. However, it has a problem that it will not check if the
replacement is a an assertion for the same condition as COND.

So, you will need to extend update_ssa's API to give you the new
names that replace an old one.  That way, you can check whether
the condition that generated the replacement is the same one as
COND.


Diego.

Index: tree-vrp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-vrp.c,v
retrieving revision 2.15
diff -d -u -p -r2.15 tree-vrp.c
--- tree-vrp.c  2 May 2005 18:06:07 -0000       2.15
+++ tree-vrp.c  4 May 2005 15:36:33 -0000
@@ -1371,6 +1440,11 @@ has_assert_expr (tree op, tree cond)
   tree def_stmt = SSA_NAME_DEF_STMT (op);
   tree assert_expr, other_cond, other_op;

+  /* If OP is registered for renaming, it means that we have already
+     generated an ASSERT_EXPR for it.  */
+  if (name_registered_for_update_p (op))
+    return true;
+
   /* If OP was not generated by an ASSERT_EXPR, return false.  */
   if (TREE_CODE (def_stmt) != MODIFY_EXPR
       || TREE_CODE (TREE_OPERAND (def_stmt, 1)) != ASSERT_EXPR)


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