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] Set has_volatile_ops only where neccessary, independent of alias grouping


This makes has_volatile_ops more consistent and less dependent on alias
grouping results.  It removes setting has_volatile_ops on non-reference
operations like

 volatile int *p = &a->x;

where we set has_volatile_ops before if p get's a NMT and the pointer
type is volatile.  It also doesn't make sense to not set has_volatile_ops
just because we don't have a statement annotation (in fact we always
have one, so I just removed those checks).

Bootstrapped and tested on x86_64-unknown-linux-gnu.

I'll apply this after waiting for comments a bit.

Thanks,
Richard.

2007-08-31  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-alias.c (create_name_tags): Use TYPE_VOLATILE
	instead of TREE_THIS_VOLATILE.
	* tree-ssa-operands.c (add_virtual_operand): Do not set
	has_volatile_ops.  Do not check s_ann for NULL.
	(get_indirect_ref_operands): Likewise.
	(get_expr_operands): Likewise.  For all reference trees
	set has_volatile_ops based on TREE_THIS_VOLATILE.  Also
	check base of reference for TREE_THIS_VOLATILE.

Index: tree-ssa-alias.c
===================================================================
*** tree-ssa-alias.c	(revision 127968)
--- tree-ssa-alias.c	(working copy)
*************** create_name_tags (void)
*** 2216,2222 ****
  
        /* Inherit volatility from the pointed-to type.  */
        TREE_THIS_VOLATILE (pi->name_mem_tag)
! 	|= TREE_THIS_VOLATILE (TREE_TYPE (TREE_TYPE (ptr)));
        
        /* Mark the new name tag for renaming.  */
        mark_sym_for_renaming (pi->name_mem_tag);
--- 2216,2222 ----
  
        /* Inherit volatility from the pointed-to type.  */
        TREE_THIS_VOLATILE (pi->name_mem_tag)
! 	|= TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (ptr)));
        
        /* Mark the new name tag for renaming.  */
        mark_sym_for_renaming (pi->name_mem_tag);
Index: tree-ssa-operands.c
===================================================================
*** tree-ssa-operands.c	(revision 127968)
--- tree-ssa-operands.c	(working copy)
*************** add_virtual_operand (tree var, stmt_ann_
*** 1466,1476 ****
    /* Mark the statement as having memory operands.  */
    s_ann->references_memory = true;
  
-   /* Mark statements with volatile operands.  Optimizers should back
-      off from statements having volatile operands.  */
-   if (TREE_THIS_VOLATILE (sym) && s_ann)
-     s_ann->has_volatile_ops = true;
- 
    /* If the variable cannot be modified and this is a VDEF change
       it into a VUSE.  This happens when read-only variables are marked
       call-clobbered and/or aliased to writable variables.  So we only
--- 1466,1471 ----
*************** add_virtual_operand (tree var, stmt_ann_
*** 1499,1505 ****
  
    if (aliases == NULL)
      {
!       if (s_ann && !gimple_aliases_computed_p (cfun))
          s_ann->has_volatile_ops = true;
  
        /* The variable is not aliased or it is an alias tag.  */
--- 1494,1500 ----
  
    if (aliases == NULL)
      {
!       if (!gimple_aliases_computed_p (cfun))
          s_ann->has_volatile_ops = true;
  
        /* The variable is not aliased or it is an alias tag.  */
*************** get_indirect_ref_operands (tree stmt, tr
*** 1630,1636 ****
    stmt_ann_t s_ann = stmt_ann (stmt);
  
    s_ann->references_memory = true;
!   if (s_ann && TREE_THIS_VOLATILE (expr))
      s_ann->has_volatile_ops = true; 
  
    if (SSA_VAR_P (ptr))
--- 1625,1631 ----
    stmt_ann_t s_ann = stmt_ann (stmt);
  
    s_ann->references_memory = true;
!   if (TREE_THIS_VOLATILE (expr))
      s_ann->has_volatile_ops = true; 
  
    if (SSA_VAR_P (ptr))
*************** get_indirect_ref_operands (tree stmt, tr
*** 1677,1684 ****
  
  	  /* Aliasing information is missing; mark statement as
  	     volatile so we won't optimize it out too actively.  */
!           else if (s_ann
! 	           && !gimple_aliases_computed_p (cfun)
                     && (flags & opf_def))
              s_ann->has_volatile_ops = true;
  	}
--- 1672,1678 ----
  
  	  /* Aliasing information is missing; mark statement as
  	     volatile so we won't optimize it out too actively.  */
!           else if (!gimple_aliases_computed_p (cfun)
                     && (flags & opf_def))
              s_ann->has_volatile_ops = true;
  	}
*************** get_indirect_ref_operands (tree stmt, tr
*** 1688,1695 ****
        /* If a constant is used as a pointer, we can't generate a real
  	 operand for it but we mark the statement volatile to prevent
  	 optimizations from messing things up.  */
!       if (s_ann)
! 	s_ann->has_volatile_ops = true;
        return;
      }
    else
--- 1682,1688 ----
        /* If a constant is used as a pointer, we can't generate a real
  	 operand for it but we mark the statement volatile to prevent
  	 optimizations from messing things up.  */
!       s_ann->has_volatile_ops = true;
        return;
      }
    else
*************** get_expr_operands (tree stmt, tree *expr
*** 2121,2126 ****
--- 2114,2122 ----
  	HOST_WIDE_INT offset, size, maxsize;
  	bool none = true;
  
+ 	if (TREE_THIS_VOLATILE (expr))
+ 	  s_ann->has_volatile_ops = true;
+ 
  	/* This component reference becomes an access to all of the
  	   subvariables it can touch, if we can determine that, but
  	   *NOT* the real one.  If we can't determine which fields we
*************** get_expr_operands (tree stmt, tree *expr
*** 2148,2155 ****
  	    if (!none)
  	      flags |= opf_no_vops;
  
! 	    if (TREE_THIS_VOLATILE (expr))
! 	      get_stmt_ann (stmt)->has_volatile_ops = true;
  	  }
  	else if (TREE_CODE (ref) == INDIRECT_REF)
  	  {
--- 2144,2153 ----
  	    if (!none)
  	      flags |= opf_no_vops;
  
! 	    if ((DECL_P (ref) && TREE_THIS_VOLATILE (ref))
! 		|| (TREE_CODE (ref) == SSA_NAME
! 		    && TREE_THIS_VOLATILE (SSA_NAME_VAR (ref))))
! 	      s_ann->has_volatile_ops = true;
  	  }
  	else if (TREE_CODE (ref) == INDIRECT_REF)
  	  {
*************** get_expr_operands (tree stmt, tree *expr
*** 2165,2171 ****
  	
  	if (code == COMPONENT_REF)
  	  {
! 	    if (s_ann && TREE_THIS_VOLATILE (TREE_OPERAND (expr, 1)))
  	      s_ann->has_volatile_ops = true; 
  	    get_expr_operands (stmt, &TREE_OPERAND (expr, 2), opf_use);
  	  }
--- 2163,2169 ----
  	
  	if (code == COMPONENT_REF)
  	  {
! 	    if (TREE_THIS_VOLATILE (TREE_OPERAND (expr, 1)))
  	      s_ann->has_volatile_ops = true; 
  	    get_expr_operands (stmt, &TREE_OPERAND (expr, 2), opf_use);
  	  }


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