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][mem-ref2] Various small bits


Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to the 
branch.

Richard.

2010-06-18  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-loop-niter.c (array_at_struct_end_p): Handle MEM_REF.
	* tree-ssa-sccvn.c (ao_ref_init_from_vn_reference): Do not
	handle INDIRECT_REF.
	* expr.c (get_inner_reference): Cleanup.
	* tree-vect-data-refs.c (vect_create_addr_base_for_vector_ref): Do
	not handle INDIRECT_REF.
	* tree-ssa-phiopt.c: Replace INDIRECT_REF with MEM_REF in comments.
	* tree-dfa.c (get_ref_base_and_extent): Cleanup.
	* tree-ssa-pre.c (can_PRE_operation): Do not handle INDIRECT_REF.
	Handle MEM_REF.
	(create_component_ref_by_pieces_1): Do not handle INDIRECT_REF.

Index: gcc/tree-ssa-loop-niter.c
===================================================================
*** gcc/tree-ssa-loop-niter.c	(revision 160880)
--- gcc/tree-ssa-loop-niter.c	(working copy)
*************** array_at_struct_end_p (tree ref)
*** 2625,2631 ****
  
    /* Unless the reference is through a pointer, the size of the array matches
       its declaration.  */
!   if (!base || !INDIRECT_REF_P (base))
      return false;
  
    for (;handled_component_p (ref); ref = parent)
--- 2625,2631 ----
  
    /* Unless the reference is through a pointer, the size of the array matches
       its declaration.  */
!   if (!base || (!INDIRECT_REF_P (base) && TREE_CODE (base) != MEM_REF))
      return false;
  
    for (;handled_component_p (ref); ref = parent)
*************** array_at_struct_end_p (tree ref)
*** 2651,2657 ****
  	 Therefore, continue checking.  */
      }
  
-   gcc_assert (INDIRECT_REF_P (ref));
    return true;
  }
  
--- 2651,2656 ----
Index: gcc/tree-ssa-sccvn.c
===================================================================
*** gcc/tree-ssa-sccvn.c	(revision 160920)
--- gcc/tree-ssa-sccvn.c	(working copy)
*************** ao_ref_init_from_vn_reference (ao_ref *r
*** 789,795 ****
  
  	/* Record the base objects.  */
  	case ALIGN_INDIRECT_REF:
- 	case INDIRECT_REF:
  	  *op0_p = build1 (op->opcode, op->type, NULL_TREE);
  	  op0_p = &TREE_OPERAND (*op0_p, 0);
  	  break;
--- 789,794 ----
Index: gcc/expr.c
===================================================================
*** gcc/expr.c	(revision 160920)
--- gcc/expr.c	(working copy)
*************** get_inner_reference (tree exp, HOST_WIDE
*** 6109,6124 ****
  	  break;
  
  	case MEM_REF:
! 	  /* ???  We should avoid doing this when doing so hides
! 	     the effective alias set.  */
  	  if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR)
  	    {
  	      tree off = TREE_OPERAND (exp, 1);
  	      if (!integer_zerop (off))
  		{
  		  double_int boff, coff = mem_ref_offset (exp);
! 		  boff = double_int_lshift (coff, exact_log2 (BITS_PER_UNIT),
! 					    2 * HOST_BITS_PER_WIDE_INT, 1);
  		  bit_offset
  		    = size_binop (PLUS_EXPR, bit_offset,
  				  double_int_to_tree (bitsizetype, boff));
--- 6109,6125 ----
  	  break;
  
  	case MEM_REF:
! 	  /* Hand back the decl for MEM[&decl, off].  */
  	  if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR)
  	    {
  	      tree off = TREE_OPERAND (exp, 1);
  	      if (!integer_zerop (off))
  		{
  		  double_int boff, coff = mem_ref_offset (exp);
! 		  boff = double_int_lshift (coff,
! 					    BITS_PER_UNIT == 8
! 					    ? 3 : exact_log2 (BITS_PER_UNIT),
! 					    HOST_BITS_PER_DOUBLE_INT, true);
  		  bit_offset
  		    = size_binop (PLUS_EXPR, bit_offset,
  				  double_int_to_tree (bitsizetype, boff));
Index: gcc/tree-vect-data-refs.c
===================================================================
*** gcc/tree-vect-data-refs.c	(revision 160880)
--- gcc/tree-vect-data-refs.c	(working copy)
*************** vect_create_addr_base_for_vector_ref (gi
*** 2398,2409 ****
                               data_ref_base, base_offset);
    else
      {
!       if (TREE_CODE (DR_REF (dr)) == INDIRECT_REF)
!         addr_base = unshare_expr (TREE_OPERAND (DR_REF (dr), 0));
!       else
!         addr_base = build1 (ADDR_EXPR,
!                             build_pointer_type (TREE_TYPE (DR_REF (dr))),
!                             unshare_expr (DR_REF (dr)));
      }
  
    vect_ptr_type = build_pointer_type (STMT_VINFO_VECTYPE (stmt_info));
--- 2398,2406 ----
                               data_ref_base, base_offset);
    else
      {
!       addr_base = build1 (ADDR_EXPR,
! 			  build_pointer_type (TREE_TYPE (DR_REF (dr))),
! 			  unshare_expr (DR_REF (dr)));
      }
  
    vect_ptr_type = build_pointer_type (STMT_VINFO_VECTYPE (stmt_info));
Index: gcc/tree-ssa-phiopt.c
===================================================================
*** gcc/tree-ssa-phiopt.c	(revision 160880)
--- gcc/tree-ssa-phiopt.c	(working copy)
*************** abs_replacement (basic_block cond_bb, ba
*** 994,1003 ****
  
  /* Auxiliary functions to determine the set of memory accesses which
     can't trap because they are preceded by accesses to the same memory
!    portion.  We do that for INDIRECT_REFs, so we only need to track
     the SSA_NAME of the pointer indirectly referenced.  The algorithm
     simply is a walk over all instructions in dominator order.  When
!    we see an INDIRECT_REF we determine if we've already seen a same
     ref anywhere up to the root of the dominator tree.  If we do the
     current access can't trap.  If we don't see any dominating access
     the current access might trap, but might also make later accesses
--- 994,1003 ----
  
  /* Auxiliary functions to determine the set of memory accesses which
     can't trap because they are preceded by accesses to the same memory
!    portion.  We do that for MEM_REFs, so we only need to track
     the SSA_NAME of the pointer indirectly referenced.  The algorithm
     simply is a walk over all instructions in dominator order.  When
!    we see an MEM_REF we determine if we've already seen a same
     ref anywhere up to the root of the dominator tree.  If we do the
     current access can't trap.  If we don't see any dominating access
     the current access might trap, but might also make later accesses
*************** abs_replacement (basic_block cond_bb, ba
*** 1011,1017 ****
     trap even if a store doesn't (write-only memory).  This probably is
     overly conservative.  */
  
! /* A hash-table of SSA_NAMEs, and in which basic block an INDIRECT_REF
     through it was seen, which would constitute a no-trap region for
     same accesses.  */
  struct name_to_bb
--- 1011,1017 ----
     trap even if a store doesn't (write-only memory).  This probably is
     overly conservative.  */
  
! /* A hash-table of SSA_NAMEs, and in which basic block an MEM_REF
     through it was seen, which would constitute a no-trap region for
     same accesses.  */
  struct name_to_bb
*************** struct name_to_bb
*** 1024,1030 ****
  /* The hash table for remembering what we've seen.  */
  static htab_t seen_ssa_names;
  
! /* The set of INDIRECT_REFs which can't trap.  */
  static struct pointer_set_t *nontrap_set;
  
  /* The hash function, based on the pointer to the pointer SSA_NAME.  */
--- 1024,1030 ----
  /* The hash table for remembering what we've seen.  */
  static htab_t seen_ssa_names;
  
! /* The set of MEM_REFs which can't trap.  */
  static struct pointer_set_t *nontrap_set;
  
  /* The hash function, based on the pointer to the pointer SSA_NAME.  */
*************** name_to_bb_eq (const void *p1, const voi
*** 1047,1053 ****
  }
  
  /* We see the expression EXP in basic block BB.  If it's an interesting
!    expression (an INDIRECT_REF through an SSA_NAME) possibly insert the
     expression into the set NONTRAP or the hash table of seen expressions.
     STORE is true if this expression is on the LHS, otherwise it's on
     the RHS.  */
--- 1047,1053 ----
  }
  
  /* We see the expression EXP in basic block BB.  If it's an interesting
!    expression (an MEM_REF through an SSA_NAME) possibly insert the
     expression into the set NONTRAP or the hash table of seen expressions.
     STORE is true if this expression is on the LHS, otherwise it's on
     the RHS.  */
*************** add_or_mark_expr (basic_block bb, tree e
*** 1064,1070 ****
        struct name_to_bb *n2bb;
        basic_block found_bb = 0;
  
!       /* Try to find the last seen INDIRECT_REF through the same
           SSA_NAME, which can trap.  */
        map.ssa_name = name;
        map.bb = 0;
--- 1064,1070 ----
        struct name_to_bb *n2bb;
        basic_block found_bb = 0;
  
!       /* Try to find the last seen MEM_REF through the same
           SSA_NAME, which can trap.  */
        map.ssa_name = name;
        map.bb = 0;
*************** add_or_mark_expr (basic_block bb, tree e
*** 1074,1080 ****
        if (n2bb)
          found_bb = n2bb->bb;
  
!       /* If we've found a trapping INDIRECT_REF, _and_ it dominates EXP
           (it's in a basic block on the path from us to the dominator root)
  	 then we can't trap.  */
        if (found_bb && found_bb->aux == (void *)1)
--- 1074,1080 ----
        if (n2bb)
          found_bb = n2bb->bb;
  
!       /* If we've found a trapping MEM_REF, _and_ it dominates EXP
           (it's in a basic block on the path from us to the dominator root)
  	 then we can't trap.  */
        if (found_bb && found_bb->aux == (void *)1)
*************** nt_fini_block (struct dom_walk_data *dat
*** 1135,1141 ****
  /* This is the entry point of gathering non trapping memory accesses.
     It will do a dominator walk over the whole function, and it will
     make use of the bb->aux pointers.  It returns a set of trees
!    (the INDIRECT_REFs itself) which can't trap.  */
  static struct pointer_set_t *
  get_non_trapping (void)
  {
--- 1135,1141 ----
  /* This is the entry point of gathering non trapping memory accesses.
     It will do a dominator walk over the whole function, and it will
     make use of the bb->aux pointers.  It returns a set of trees
!    (the MEM_REFs itself) which can't trap.  */
  static struct pointer_set_t *
  get_non_trapping (void)
  {
Index: gcc/tree-dfa.c
===================================================================
*** gcc/tree-dfa.c	(revision 160920)
--- gcc/tree-dfa.c	(working copy)
*************** get_ref_base_and_extent (tree exp, HOST_
*** 869,888 ****
  	  break;
  
  	case MEM_REF:
! 	  /* ???  We should avoid doing this when doing so hides 
! 	     the effective alias set.  */
! 	  if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
! 	      /* We do need to handle large offsets here, for example
! 	         from gcc.c-torture/compile/pr28489.c.  Thus the whole
! 		 function should probably be audited for overflowing
! 		 bit_offset ...
! 		 Also we need to treat the pointer constants as
! 		 sign-extending.  */
! 	      && (TREE_INT_CST_HIGH (TREE_OPERAND (exp, 1)) == -1
! 		  || host_integerp (TREE_OPERAND (exp, 1), 0)))
  	    {
! 	      bit_offset += mem_ref_offset (exp).low * BITS_PER_UNIT;
! 	      exp = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
  	    }
  	  goto done;
  
--- 869,893 ----
  	  break;
  
  	case MEM_REF:
! 	  /* Hand back the decl for MEM[&decl, off].  */
! 	  if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR)
  	    {
! 	      if (integer_zerop (TREE_OPERAND (exp, 1)))
! 		exp = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
! 	      else
! 		{
! 		  double_int off = mem_ref_offset (exp);
! 		  off = double_int_lshift (off,
! 					   BITS_PER_UNIT == 8
! 					   ? 3 : exact_log2 (BITS_PER_UNIT),
! 					   HOST_BITS_PER_DOUBLE_INT, true);
! 		  off = double_int_add (off, shwi_to_double_int (bit_offset));
! 		  if (double_int_fits_in_shwi_p (off))
! 		    {
! 		      bit_offset = double_int_to_shwi (off);
! 		      exp = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
! 		    }
! 		}
  	    }
  	  goto done;
  
Index: gcc/tree-ssa-pre.c
===================================================================
*** gcc/tree-ssa-pre.c	(revision 160920)
--- gcc/tree-ssa-pre.c	(working copy)
*************** can_PRE_operation (tree op)
*** 2598,2604 ****
    return UNARY_CLASS_P (op)
      || BINARY_CLASS_P (op)
      || COMPARISON_CLASS_P (op)
!     || TREE_CODE (op) == INDIRECT_REF
      || TREE_CODE (op) == COMPONENT_REF
      || TREE_CODE (op) == VIEW_CONVERT_EXPR
      || TREE_CODE (op) == CALL_EXPR
--- 2598,2604 ----
    return UNARY_CLASS_P (op)
      || BINARY_CLASS_P (op)
      || COMPARISON_CLASS_P (op)
!     || TREE_CODE (op) == MEM_REF 
      || TREE_CODE (op) == COMPONENT_REF
      || TREE_CODE (op) == VIEW_CONVERT_EXPR
      || TREE_CODE (op) == CALL_EXPR
*************** create_component_ref_by_pieces_1 (basic_
*** 2751,2757 ****
        break;
      case ALIGN_INDIRECT_REF:
      case MISALIGNED_INDIRECT_REF:
-     case INDIRECT_REF:
        {
  	tree folded;
  	tree genop1 = create_component_ref_by_pieces_1 (block, ref,
--- 2751,2756 ----
*************** create_component_ref_by_pieces_1 (basic_
*** 2903,2909 ****
  }
  
  /* For COMPONENT_REF's and ARRAY_REF's, we can't have any intermediates for the
!    COMPONENT_REF or INDIRECT_REF or ARRAY_REF portion, because we'd end up with
     trying to rename aggregates into ssa form directly, which is a no no.
  
     Thus, this routine doesn't create temporaries, it just builds a
--- 2902,2908 ----
  }
  
  /* For COMPONENT_REF's and ARRAY_REF's, we can't have any intermediates for the
!    COMPONENT_REF or MEM_REF or ARRAY_REF portion, because we'd end up with
     trying to rename aggregates into ssa form directly, which is a no no.
  
     Thus, this routine doesn't create temporaries, it just builds a


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