Patchwork don't copy arguments when folding gimple stmts

login
register
mail settings
Submitter Nathan Froyd
Date Oct. 8, 2010, 8:46 p.m.
Message ID <20101008204654.GS17388@nightcrawler>
Download mbox | patch
Permalink /patch/67283/
State New
Headers show

Comments

Nathan Froyd - Oct. 8, 2010, 8:46 p.m.
fold_call_stmt copies arguments out of a GIMPLE_CALL onto a temporary
array before passing that array off to fold_builtin_n.  There's no need
to do this; we can read the arguments directly from the stmt with
gimple_call_arg_ptr, which is what the patch below does.

Bootstrapped on x86_64-unknown-linux-gnu.  OK to commit?

-Nathan

	* builtins.c (fold_call_stmt): Don't copy gimple call arguments
	into a temporary array.
Diego Novillo - Oct. 9, 2010, 12:02 a.m.
On Fri, Oct 8, 2010 at 13:46, Nathan Froyd <froydnj@codesourcery.com> wrote:

>        * builtins.c (fold_call_stmt): Don't copy gimple call arguments
>        into a temporary array.

OK.


Diego.

Patch

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 0579f75..1764cb4 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -13627,26 +13627,20 @@  fold_call_stmt (gimple stmt, bool ignore)
       && !gimple_call_va_arg_pack_p (stmt))
     {
       int nargs = gimple_call_num_args (stmt);
+      tree *args = (nargs > 0
+		    ? gimple_call_arg_ptr (stmt, 0)
+		    : &error_mark_node);
 
       if (avoid_folding_inline_builtin (fndecl))
 	return NULL_TREE;
       if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
         {
-	  return targetm.fold_builtin (fndecl, nargs,
-				       (nargs > 0
-					? gimple_call_arg_ptr (stmt, 0)
-					: &error_mark_node), ignore);
+	  return targetm.fold_builtin (fndecl, nargs, args, ignore);
         }
       else
 	{
 	  if (nargs <= MAX_ARGS_TO_FOLD_BUILTIN)
-	    {
-              tree args[MAX_ARGS_TO_FOLD_BUILTIN];
-              int i;
-              for (i = 0; i < nargs; i++)
-                args[i] = gimple_call_arg (stmt, i);
-	      ret = fold_builtin_n (loc, fndecl, args, nargs, ignore);
-	    }
+	    ret = fold_builtin_n (loc, fndecl, args, nargs, ignore);
 	  if (!ret)
 	    ret = gimple_fold_builtin_varargs (fndecl, stmt, ignore);
 	  if (ret)