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] More type fallout


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

Ok for mainline?

Richard.


2005-06-02  Richard Guenther  <rguenth@gcc.gnu.org>

	* c-typeck.c (build_indirect_ref): Build INDIRECT_REF
	with correct type.
	* fold-const.c (fold_single_bit_test): Use build_int_cst with
	correct type.
	(fold_unary): Adjust type of Y in folding of (T1)((T2)X op Y)
	to (T1)X op Y.
	* tree-data-ref.c (estimate_niter_from_size_of_data):
	Use int_const_binop for constant bitsizetype type arguments
	from TYPE_SIZE.


Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.446
diff -c -3 -p -r1.446 c-typeck.c
*** c-typeck.c	25 May 2005 03:58:56 -0000	1.446
--- c-typeck.c	2 Jun 2005 09:38:39 -0000
*************** build_indirect_ref (tree ptr, const char
*** 1638,1649 ****
        else
  	{
  	  tree t = TREE_TYPE (type);
- 	  tree mvt = t;
  	  tree ref;

! 	  if (TREE_CODE (mvt) != ARRAY_TYPE)
! 	    mvt = TYPE_MAIN_VARIANT (mvt);
! 	  ref = build1 (INDIRECT_REF, mvt, pointer);

  	  if (!COMPLETE_OR_VOID_TYPE_P (t) && TREE_CODE (t) != ARRAY_TYPE)
  	    {
--- 1638,1646 ----
        else
  	{
  	  tree t = TREE_TYPE (type);
  	  tree ref;

! 	  ref = build1 (INDIRECT_REF, t, pointer);

  	  if (!COMPLETE_OR_VOID_TYPE_P (t) && TREE_CODE (t) != ARRAY_TYPE)
  	    {
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.590
diff -c -3 -p -r1.590 fold-const.c
*** fold-const.c	2 Jun 2005 02:57:00 -0000	1.590
--- fold-const.c	2 Jun 2005 09:38:39 -0000
*************** fold_single_bit_test (enum tree_code cod
*** 6115,6125 ****

        if (code == EQ_EXPR)
  	inner = fold_build2 (BIT_XOR_EXPR, intermediate_type,
! 			     inner, integer_one_node);

        /* Put the AND last so it can combine with more things.  */
        inner = build2 (BIT_AND_EXPR, intermediate_type,
! 		      inner, integer_one_node);

        /* Make sure to return the proper type.  */
        inner = fold_convert (result_type, inner);
--- 6118,6129 ----

        if (code == EQ_EXPR)
  	inner = fold_build2 (BIT_XOR_EXPR, intermediate_type,
! 			     inner,
! 			     build_int_cst (intermediate_type, 1));

        /* Put the AND last so it can combine with more things.  */
        inner = build2 (BIT_AND_EXPR, intermediate_type,
! 		      inner, build_int_cst (intermediate_type, 1));

        /* Make sure to return the proper type.  */
        inner = fold_convert (result_type, inner);
*************** fold_unary (enum tree_code code, tree ty
*** 7054,7077 ****
  	    }
  	}

!       /* Convert (T1)((T2)X op Y) into (T1)X op Y, for pointer types T1 and
! 	 T2 being pointers to types of the same size.  */
        if (POINTER_TYPE_P (type)
  	  && BINARY_CLASS_P (arg0)
  	  && TREE_CODE (TREE_OPERAND (arg0, 0)) == NOP_EXPR
  	  && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (arg0, 0))))
  	{
! 	  tree arg00 = TREE_OPERAND (arg0, 0);
! 	  tree t0 = type;
! 	  tree t1 = TREE_TYPE (arg00);
! 	  tree tt0 = TREE_TYPE (t0);
! 	  tree tt1 = TREE_TYPE (t1);
! 	  tree s0 = TYPE_SIZE (tt0);
! 	  tree s1 = TYPE_SIZE (tt1);
!
! 	  if (s0 && s1 && operand_equal_p (s0, s1, OEP_ONLY_CONST))
! 	    return build2 (TREE_CODE (arg0), t0, fold_convert (t0, arg00),
! 			   TREE_OPERAND (arg0, 1));
  	}

        tem = fold_convert_const (code, type, arg0);
--- 7058,7081 ----
  	    }
  	}

!       /* Convert (T1)((T2)X op Y) into (T1)X op (T1)Y, for types
! 	 T1 and T2 being pointers to types of the same size.  */
        if (POINTER_TYPE_P (type)
  	  && BINARY_CLASS_P (arg0)
  	  && TREE_CODE (TREE_OPERAND (arg0, 0)) == NOP_EXPR
  	  && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (arg0, 0))))
  	{
! 	  tree arg_t2x = TREE_OPERAND (arg0, 0);
! 	  tree arg_y = TREE_OPERAND (arg0, 1);
! 	  tree t1 = type;
! 	  tree t2 = TREE_TYPE (arg_t2x);
! 	  tree s1 = TYPE_SIZE (TREE_TYPE (t1));
! 	  tree s2 = TYPE_SIZE (TREE_TYPE (t2));
!
! 	  if (s1 && s2 && operand_equal_p (s1, s2, OEP_ONLY_CONST))
! 	    return fold_build2 (TREE_CODE (arg0), t1,
! 				fold_convert (t1, arg_t2x),
! 				fold_convert (t1, arg_y));
  	}

        tem = fold_convert_const (code, type, arg0);
Index: tree-data-ref.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-data-ref.c,v
retrieving revision 2.30
diff -c -3 -p -r2.30 tree-data-ref.c
*** tree-data-ref.c	1 Jun 2005 02:50:55 -0000	2.30
--- tree-data-ref.c	2 Jun 2005 09:38:40 -0000
*************** estimate_niter_from_size_of_data (struct
*** 498,505 ****
        || TREE_CODE (element_size) != INTEGER_CST)
      return;

!   data_size = fold (build2 (EXACT_DIV_EXPR, integer_type_node,
! 			    array_size, element_size));

    if (init != NULL_TREE
        && step != NULL_TREE
--- 498,505 ----
        || TREE_CODE (element_size) != INTEGER_CST)
      return;

!   data_size = int_const_binop (EXACT_DIV_EXPR,
! 			       array_size, element_size, 0);

    if (init != NULL_TREE
        && step != NULL_TREE



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