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]

Re: [PATCH] improve C++ code by changing fold-const.c



On May 16, 2004, at 20:13, Eric Christopher wrote:



OK? Bootstrapped on powerpc-apple-darwin with no regressions.

Comment would be good.

Here:



Index: fold-const.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v retrieving revision 1.376 diff -u -p -r1.376 fold-const.c --- fold-const.c 15 May 2004 23:07:49 -0000 1.376 +++ fold-const.c 17 May 2004 00:30:00 -0000 @@ -5815,6 +5815,20 @@ fold (tree expr) if (TREE_TYPE (TREE_OPERAND (t, 0)) == type) return TREE_OPERAND (t, 0);

+      /* If we have cast then an address express and the
+	 types are both pointer types and the what they
+	 point to, then just create a new address express.  */
+      if (TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR)
+	{
+	  tree inside_tree = TREE_OPERAND (t, 0);
+	  tree inside_type = TREE_TYPE (inside_tree);
+	  if (POINTER_TYPE_P (inside_type)
+	      && POINTER_TYPE_P (type)
+	      && lang_hooks.types_compatible_p (TREE_TYPE (type),
+						TREE_TYPE (inside_type)))
+	    return build (ADDR_EXPR, type, TREE_OPERAND (inside_tree, 0));
+	}
+
       /* Handle cases of two conversions in a row.  */
       if (TREE_CODE (TREE_OPERAND (t, 0)) == NOP_EXPR
 	  || TREE_CODE (TREE_OPERAND (t, 0)) == CONVERT_EXPR)


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