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]: cleanup more builtins 3/5


Part 3/5.  Ok for mainline?


2004-10-01  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* builtins.c (expand_builtin_memmove): Delete duplicate code.
	(fold_builtin_memmove): Adjust function to take an arglist.

diff -rup orig/egcc-CVS20040930/gcc/builtins.c egcc-CVS20040930/gcc/builtins.c
--- orig/egcc-CVS20040930/gcc/builtins.c	2004-10-01 10:21:01.557496787 -0400
+++ egcc-CVS20040930/gcc/builtins.c	2004-10-01 10:34:54.447668670 -0400
@@ -2748,27 +2748,15 @@ expand_builtin_memmove (tree arglist, rt
       unsigned int src_align = get_pointer_alignment (src, BIGGEST_ALIGNMENT);
       unsigned int dest_align
 	= get_pointer_alignment (dest, BIGGEST_ALIGNMENT);
+      tree result = fold_builtin_memmove (arglist);
+
+      if (result)
+	expand_expr (result, target, mode, EXPAND_NORMAL);
 
       /* If DEST is not a pointer type, call the normal function.  */
       if (dest_align == 0)
 	return 0;
 
-      /* If the LEN parameter is zero, return DEST.  */
-      if (integer_zerop (len))
-	{
-	  /* Evaluate and ignore SRC in case it has side-effects.  */
-	  expand_expr (src, const0_rtx, VOIDmode, EXPAND_NORMAL);
-	  return expand_expr (dest, target, mode, EXPAND_NORMAL);
-	}
-
-      /* If SRC and DEST are the same (and not volatile), return DEST.  */
-      if (operand_equal_p (src, dest, 0))
-	{
-	  /* Evaluate and ignore LEN in case it has side-effects.  */
-	  expand_expr (len, const0_rtx, VOIDmode, EXPAND_NORMAL);
-	  return expand_expr (dest, target, mode, EXPAND_NORMAL);
-	}
-
       /* If either SRC is not a pointer type, don't do this
          operation in-line.  */
       if (src_align == 0)
@@ -7169,9 +7157,8 @@ fold_builtin_mempcpy (tree exp)
    NULL_TREE if no simplification can be made.  */
 
 static tree
-fold_builtin_memmove (tree exp)
+fold_builtin_memmove (tree arglist)
 {
-  tree arglist = TREE_OPERAND (exp, 1);
   tree dest, src, len;
 
   if (!validate_arglist (arglist,
@@ -7184,11 +7171,11 @@ fold_builtin_memmove (tree exp)
 
   /* If the LEN parameter is zero, return DEST.  */
   if (integer_zerop (len))
-    return omit_one_operand (TREE_TYPE (exp), dest, src);
+    return omit_one_operand (ptr_type_node, dest, src);
 
   /* If SRC and DEST are the same (and not volatile), return DEST.  */
   if (operand_equal_p (src, dest, 0))
-    return omit_one_operand (TREE_TYPE (exp), dest, len);
+    return omit_one_operand (ptr_type_node, dest, len);
 
   return 0;
 }
@@ -8134,7 +8121,7 @@ fold_builtin_1 (tree exp, bool ignore)
       return fold_builtin_mempcpy (exp);
 
     case BUILT_IN_MEMMOVE:
-      return fold_builtin_memmove (exp);
+      return fold_builtin_memmove (arglist);
 
     case BUILT_IN_SIGNBIT:
     case BUILT_IN_SIGNBITF:


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