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] make data dependence analyzer more strict


Giovanni Bajo wrote:
> 
> Is it enough to mark set_mem_alias_set with attribute pure?

Yes, but gcc is too smart on this testcase and removes all the loads
with this patch:

*** ltrans-5.c.~1.2.~	2005-04-04 13:57:47.000000000 +0200
--- ltrans-5.c	2005-05-09 18:20:05.092585552 +0200
***************
*** 4,10 ****
  {
  } *rtx;
  static rtx regno_save_mem[53][16 / 4 + 1];
! extern set_mem_alias_set (rtx, rtx);
  int main(void)
  {
    int i, j;
--- 4,10 ----
  {
  } *rtx;
  static rtx regno_save_mem[53][16 / 4 + 1];
! extern set_mem_alias_set (rtx, rtx) __attribute__((__pure__));
  int main(void)
  {
    int i, j;


I have bootstrapped (c only) on amd64 and tested the following patch.
This adds the case of loads that are parameters to call_exprs.
ltrans-5.c is still failing.


Index: tree-data-ref.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-data-ref.c,v
retrieving revision 2.26
diff -c -r2.26 tree-data-ref.c
*** tree-data-ref.c	3 May 2005 12:19:36 -0000	2.26
--- tree-data-ref.c	9 May 2005 16:22:29 -0000
***************
*** 2232,2259 ****
          {
  	  tree stmt = bsi_stmt (bsi);
  
! 	  if (TREE_CODE (stmt) != MODIFY_EXPR)
! 	    continue;
  
  	  if (ZERO_SSA_OPERANDS (stmt, SSA_OP_ALL_VIRTUALS))
  	    continue;
! 	  
! 	  /* In the GIMPLE representation, a modify expression
!   	     contains a single load or store to memory.  */
! 	  if (TREE_CODE (TREE_OPERAND (stmt, 0)) == ARRAY_REF)
! 	    VARRAY_PUSH_GENERIC_PTR 
! 		    (*datarefs, analyze_array (stmt, TREE_OPERAND (stmt, 0), 
! 					       false));
! 
! 	  else if (TREE_CODE (TREE_OPERAND (stmt, 1)) == ARRAY_REF)
! 	    VARRAY_PUSH_GENERIC_PTR 
! 		    (*datarefs, analyze_array (stmt, TREE_OPERAND (stmt, 1), 
! 					       true));
!   	  else
  	    {
  	      if (dont_know_node_not_inserted)
  		{
  		  struct data_reference *res;
  		  res = xmalloc (sizeof (struct data_reference));
  		  DR_STMT (res) = NULL_TREE;
  		  DR_REF (res) = NULL_TREE;
--- 2232,2294 ----
          {
  	  tree stmt = bsi_stmt (bsi);
  
! 	  /* ASM_EXPR and CALL_EXPR may embed arbitrary side effects.
! 	     Calls have side-effects, except those to const or pure
! 	     functions.  */
! 	  if (dont_know_node_not_inserted
! 	      && ((TREE_CODE (stmt) == CALL_EXPR
! 		   && !(call_expr_flags (stmt) & (ECF_CONST | ECF_PURE)))
! 		  || TREE_CODE (stmt) == ASM_EXPR))
! 	    goto insert_dont_know_node;
  
  	  if (ZERO_SSA_OPERANDS (stmt, SSA_OP_ALL_VIRTUALS))
  	    continue;
! 
! 	  switch (TREE_CODE (stmt))
  	    {
+ 	    case MODIFY_EXPR:
+ 	      if (TREE_CODE (TREE_OPERAND (stmt, 0)) == ARRAY_REF)
+ 		VARRAY_PUSH_GENERIC_PTR 
+ 		  (*datarefs, analyze_array (stmt, TREE_OPERAND (stmt, 0),
+ 					     false));
+ 
+ 	      if (TREE_CODE (TREE_OPERAND (stmt, 1)) == ARRAY_REF)
+ 		VARRAY_PUSH_GENERIC_PTR 
+ 		  (*datarefs, analyze_array (stmt, TREE_OPERAND (stmt, 1),
+ 					     true));
+ 
+ 	      if (dont_know_node_not_inserted
+ 		  && TREE_CODE (TREE_OPERAND (stmt, 0)) != ARRAY_REF
+ 		  && TREE_CODE (TREE_OPERAND (stmt, 1)) != ARRAY_REF)
+ 		goto insert_dont_know_node;
+ 
+ 	      break;
+ 
+ 	    case CALL_EXPR:
+ 	      {
+ 		tree args;
+ 		bool one_inserted = false;
+ 
+ 		for (args = TREE_OPERAND (stmt, 1); args; args = TREE_CHAIN (args))
+ 		  if (TREE_CODE (TREE_VALUE (args)) == ARRAY_REF)
+ 		    {
+ 		      VARRAY_PUSH_GENERIC_PTR 
+ 			(*datarefs, analyze_array (stmt, TREE_VALUE (args), true));
+ 		      one_inserted = true;
+ 		    }
+ 
+ 		if (dont_know_node_not_inserted && !one_inserted)
+ 		  goto insert_dont_know_node;
+ 
+ 		break;
+ 	      }
+ 
+ 	    default:
  	      if (dont_know_node_not_inserted)
  		{
  		  struct data_reference *res;
+ 
+ 		insert_dont_know_node:;
  		  res = xmalloc (sizeof (struct data_reference));
  		  DR_STMT (res) = NULL_TREE;
  		  DR_REF (res) = NULL_TREE;


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