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]

[tree-ssa] tree-ssa-dom improvement


Dynamically allocated stack space never lives at location zero.  This
isn't quite enough to fix 20030807-2.c, but it's definitely one of the
requirements.

	* tree-ssa-dom.c (optimize_stmt): Addresses of non-weak symbols
	as well as dynamically allocated stack space are always nonzero.

Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dom.c,v
retrieving revision 1.1.2.43
diff -c -3 -p -r1.1.2.43 tree-ssa-dom.c
*** tree-ssa-dom.c	22 Sep 2003 01:41:45 -0000	1.1.2.43
--- tree-ssa-dom.c	23 Sep 2003 07:18:58 -0000
*************** optimize_stmt (block_stmt_iterator si, v
*** 1220,1225 ****
--- 1220,1227 ----
    if (TREE_CODE (stmt) == MODIFY_EXPR)
      {
        int i;
+       tree lhs = TREE_OPERAND (stmt, 0);
+       tree rhs = TREE_OPERAND (stmt, 1);
  
        /* Look at both sides for pointer dereferences.  If we find one, then
           the pointer must be nonnull and we can enter that equivalence into
*************** optimize_stmt (block_stmt_iterator si, v
*** 1268,1275 ****
  	{
  	  tree new;
  	  size_t j;
- 	  tree lhs = TREE_OPERAND (stmt, 0);
- 	  tree rhs = TREE_OPERAND (stmt, 1);
  
  	  /* FIXME: If the LHS of the assignment is a bitfield and the RHS
  	     is a constant, we need to adjust the constant to fit into the
--- 1270,1275 ----
*************** optimize_stmt (block_stmt_iterator si, v
*** 1309,1314 ****
--- 1309,1338 ----
  	    }
  	}
  
+       /* alloca never returns zero and the address of a non-weak symbol
+ 	 is never zero.  */
+       if (TREE_CODE (TREE_OPERAND (stmt, 0)) == SSA_NAME)
+ 	{
+ 	  if (alloca_call_p (rhs)
+ 	      || (TREE_CODE (TREE_OPERAND (stmt, 1)) == ADDR_EXPR
+ 		  && DECL_P (TREE_OPERAND (TREE_OPERAND (stmt, 1), 0))
+ 		  && ! DECL_WEAK (TREE_OPERAND (TREE_OPERAND (stmt, 1), 0))))
+ 	    {
+ 	      tree cond;
+ 
+ 	      cond = build (EQ_EXPR, boolean_type_node,
+ 			    lhs, null_pointer_node);
+ 	      record_cond_is_false (cond,
+ 				    block_avail_exprs_p,
+ 				    const_and_copies);
+ 
+ 	      cond = build (NE_EXPR, boolean_type_node,
+ 			    lhs, null_pointer_node);
+ 	      record_cond_is_true (cond,
+ 				   block_avail_exprs_p,
+ 				   const_and_copies);
+ 	    }
+ 	}
      }
  
    /* If STMT is a COND_EXPR and it was modified, then we may know




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