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] Fix some type errors


Bootstrapped and tested on x86_64-unknown-linux-gnu.
Ok for mainline?

Thanks,
Richard.


2005-05-18  Richard Guenther  <rguenth@gcc.gnu.org>

	* fold-const.c (fold_binary): Fix type of created
	INDIRECT_REF node.

Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.581
diff -c -3 -p -r1.581 fold-const.c
*** fold-const.c	17 May 2005 09:55:20 -0000	1.581
--- fold-const.c	18 May 2005 13:28:19 -0000
*************** fold_binary (enum tree_code code, tree t
*** 9889,9899 ****
  	      && (arglist = TREE_OPERAND (arg0, 1))
  	      && TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) == POINTER_TYPE
  	      && ! TREE_CHAIN (arglist))
! 	    return fold_build2 (code, type,
! 				build1 (INDIRECT_REF, char_type_node,
! 					TREE_VALUE (arglist)),
! 				fold_convert (char_type_node,
! 					      integer_zero_node));
  	}

        /* We can fold X/C1 op C2 where C1 and C2 are integer constants
--- 9901,9915 ----
  	      && (arglist = TREE_OPERAND (arg0, 1))
  	      && TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) == POINTER_TYPE
  	      && ! TREE_CHAIN (arglist))
! 	    {
! 	      tree itype = TREE_TYPE (TREE_TYPE (TREE_VALUE (arglist)));
! 	      return fold_build2 (code, type,
! 				  fold_convert (char_type_node,
! 					        build1 (INDIRECT_REF, itype,
! 					                TREE_VALUE (arglist))),
! 				  fold_convert (char_type_node,
! 					        integer_zero_node));
! 	    }
  	}

        /* We can fold X/C1 op C2 where C1 and C2 are integer constants



2005-05-18  Richard Guenther  <rguenth@gcc.gnu.org>

	* tree-ssa-loop-ivopts.c (determine_base_object): Use
	build_fold_addr_expr to generate trees of correct type.
	Use fold_buildN if possible.


Index: tree-ssa-loop-ivopts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-ivopts.c,v
retrieving revision 2.70
diff -c -3 -p -r2.70 tree-ssa-loop-ivopts.c
*** tree-ssa-loop-ivopts.c	17 May 2005 20:02:56 -0000	2.70
--- tree-ssa-loop-ivopts.c	18 May 2005 11:28:24 -0000
*************** determine_base_object (tree expr)
*** 791,797 ****
        if (TREE_CODE (base) == INDIRECT_REF)
  	return determine_base_object (TREE_OPERAND (base, 0));

!       return fold (build1 (ADDR_EXPR, ptr_type_node, base));

      case PLUS_EXPR:
      case MINUS_EXPR:
--- 791,798 ----
        if (TREE_CODE (base) == INDIRECT_REF)
  	return determine_base_object (TREE_OPERAND (base, 0));

!       return fold_convert (ptr_type_node,
! 		           build_fold_addr_expr (base));

      case PLUS_EXPR:
      case MINUS_EXPR:
*************** determine_base_object (tree expr)
*** 804,812 ****
        if (!op0)
  	return (code == PLUS_EXPR
  		? op1
! 		: fold (build1 (NEGATE_EXPR, ptr_type_node, op1)));

!       return fold (build (code, ptr_type_node, op0, op1));

      case NOP_EXPR:
      case CONVERT_EXPR:
--- 805,813 ----
        if (!op0)
  	return (code == PLUS_EXPR
  		? op1
! 		: fold_build1 (NEGATE_EXPR, ptr_type_node, op1));

!       return fold_build2 (code, ptr_type_node, op0, op1);

      case NOP_EXPR:
      case CONVERT_EXPR:


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