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] Fix some spurious testsuite FAILs


This fixes a load of testsuite fails because of changes in dumps.
The fix is to restore the old dump when there is no loss in
information.  The patch also fixes up some foldings I deleted
and fixes some VRP testcase.

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

Richard.

2010-04-08  Richard Guenther  <rguenther@suse.de>

	* tree-vrp.c (vrp_stmt_computes_nonzero): Adjust for MEM_REF.
	* tree-pretty-print.c (dump_generic_node): Print MEM_REFs
	equivalent to plain old INDIRECT_REFs as * and -> again.
	* gimplify.c (gimple_fold_indirect_ref): Restore some
	foldings.

Index: gcc/tree-vrp.c
===================================================================
*** gcc/tree-vrp.c	(revision 158124)
--- gcc/tree-vrp.c	(working copy)
*************** vrp_stmt_computes_nonzero (gimple stmt,
*** 961,967 ****
        tree base = get_base_address (TREE_OPERAND (expr, 0));
  
        if (base != NULL_TREE
! 	  && TREE_CODE (base) == INDIRECT_REF
  	  && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME)
  	{
  	  value_range_t *vr = get_value_range (TREE_OPERAND (base, 0));
--- 961,967 ----
        tree base = get_base_address (TREE_OPERAND (expr, 0));
  
        if (base != NULL_TREE
! 	  && TREE_CODE (base) == MEM_REF
  	  && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME)
  	{
  	  value_range_t *vr = get_value_range (TREE_OPERAND (base, 0));
Index: gcc/tree-pretty-print.c
===================================================================
*** gcc/tree-pretty-print.c	(revision 158111)
--- gcc/tree-pretty-print.c	(working copy)
*************** dump_generic_node (pretty_printer *buffe
*** 788,794 ****
  
      case MEM_REF:
        {
! 	if (0 && integer_zerop (TREE_OPERAND (node, 1)))
  	  {
  	    pp_string (buffer, "*");
  	    dump_generic_node (buffer, TREE_OPERAND (node, 0),
--- 788,799 ----
  
      case MEM_REF:
        {
! 	if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR
! 	    && integer_zerop (TREE_OPERAND (node, 1))
! 	    && (TREE_TYPE (TREE_OPERAND (node, 0))
! 		== TREE_TYPE (TREE_OPERAND (node, 1)))
! 	    && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
! 		== TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))))
  	  {
  	    pp_string (buffer, "*");
  	    dump_generic_node (buffer, TREE_OPERAND (node, 0),
*************** dump_generic_node (pretty_printer *buffe
*** 802,810 ****
  			       spc, flags, false);
  	    pp_string (buffer, ")");
  	    dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
! 	    pp_string (buffer, " + ");
! 	    dump_generic_node (buffer, TREE_OPERAND (node, 1),
! 			       spc, flags, false);
  	    pp_string (buffer, "]");
  	  }
  	break;
--- 807,818 ----
  			       spc, flags, false);
  	    pp_string (buffer, ")");
  	    dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
! 	    if (!integer_zerop (TREE_OPERAND (node, 1)))
! 	      {
! 		pp_string (buffer, " + ");
! 		dump_generic_node (buffer, TREE_OPERAND (node, 1),
! 				   spc, flags, false);
! 	      }
  	    pp_string (buffer, "]");
  	  }
  	break;
*************** dump_generic_node (pretty_printer *buffe
*** 1118,1125 ****
        str = ".";
        if (op0
  	  && (TREE_CODE (op0) == INDIRECT_REF
! 	      || (0 && TREE_CODE (op0) == MEM_REF
! 		  && integer_zerop (TREE_OPERAND (op0, 1)))))
  	{
  	  op0 = TREE_OPERAND (op0, 0);
  	  str = "->";
--- 1126,1138 ----
        str = ".";
        if (op0
  	  && (TREE_CODE (op0) == INDIRECT_REF
! 	      || (TREE_CODE (op0) == MEM_REF
! 		  && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
! 		  && integer_zerop (TREE_OPERAND (op0, 1))
! 		  && (TREE_TYPE (TREE_OPERAND (op0, 0))
! 		      == TREE_TYPE (TREE_OPERAND (op0, 1)))
! 		  && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
! 		      == TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))))))
  	{
  	  op0 = TREE_OPERAND (op0, 0);
  	  str = "->";
Index: gcc/gimplify.c
===================================================================
*** gcc/gimplify.c	(revision 158111)
--- gcc/gimplify.c	(working copy)
*************** gimple_fold_indirect_ref (tree t)
*** 4010,4022 ****
          }
      }
  
!   /* *(p + CST) -> MEM_REF <p, CST>.  */
    if (TREE_CODE (sub) == POINTER_PLUS_EXPR
        && TREE_CODE (TREE_OPERAND (sub, 1)) == INTEGER_CST)
      {
        tree addr = TREE_OPERAND (sub, 0);
        tree off = TREE_OPERAND (sub, 1);
        STRIP_NOPS (addr);
        if (TREE_CODE (addr) != ADDR_EXPR
  	  || DECL_P (TREE_OPERAND (addr, 0)))
  	return fold_build2 (MEM_REF, type,
--- 4010,4054 ----
          }
      }
  
!   /* *(p + CST) -> ...  */
    if (TREE_CODE (sub) == POINTER_PLUS_EXPR
        && TREE_CODE (TREE_OPERAND (sub, 1)) == INTEGER_CST)
      {
        tree addr = TREE_OPERAND (sub, 0);
        tree off = TREE_OPERAND (sub, 1);
+       tree addrtype;
+ 
        STRIP_NOPS (addr);
+       addrtype = TREE_TYPE (addr);
+ 
+       /* ((foo*)&vectorfoo)[1] -> BIT_FIELD_REF<vectorfoo,...> */
+       if (TREE_CODE (addr) == ADDR_EXPR
+ 	  && TREE_CODE (TREE_TYPE (addrtype)) == VECTOR_TYPE
+ 	  && useless_type_conversion_p (type, TREE_TYPE (TREE_TYPE (addrtype))))
+ 	{
+           HOST_WIDE_INT offset = tree_low_cst (off, 0);
+           tree part_width = TYPE_SIZE (type);
+           unsigned HOST_WIDE_INT part_widthi
+             = tree_low_cst (part_width, 0) / BITS_PER_UNIT;
+           unsigned HOST_WIDE_INT indexi = offset * BITS_PER_UNIT;
+           tree index = bitsize_int (indexi);
+           if (offset / part_widthi
+               <= TYPE_VECTOR_SUBPARTS (TREE_TYPE (addrtype)))
+             return fold_build3 (BIT_FIELD_REF, type, TREE_OPERAND (addr, 0),
+                                 part_width, index);
+ 	}
+ 
+       /* ((foo*)&complexfoo)[1] -> __imag__ complexfoo */
+       if (TREE_CODE (addr) == ADDR_EXPR
+ 	  && TREE_CODE (TREE_TYPE (addrtype)) == COMPLEX_TYPE
+ 	  && useless_type_conversion_p (type, TREE_TYPE (TREE_TYPE (addrtype))))
+         {
+           tree size = TYPE_SIZE_UNIT (type);
+           if (tree_int_cst_equal (size, off))
+             return fold_build1 (IMAGPART_EXPR, type, TREE_OPERAND (addr, 0));
+         }
+ 
+       /* *(p + CST) -> MEM_REF <p, CST>.  */
        if (TREE_CODE (addr) != ADDR_EXPR
  	  || DECL_P (TREE_OPERAND (addr, 0)))
  	return fold_build2 (MEM_REF, type,


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