From patchwork Fri Oct 8 20:46:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 67283 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 47466B70CB for ; Sat, 9 Oct 2010 07:47:05 +1100 (EST) Received: (qmail 31676 invoked by alias); 8 Oct 2010 20:47:03 -0000 Received: (qmail 31668 invoked by uid 22791); 8 Oct 2010 20:47:03 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, TW_TM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 08 Oct 2010 20:46:59 +0000 Received: (qmail 6462 invoked from network); 8 Oct 2010 20:46:57 -0000 Received: from unknown (HELO codesourcery.com) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 8 Oct 2010 20:46:57 -0000 Date: Fri, 8 Oct 2010 16:46:55 -0400 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Subject: [PATCH] don't copy arguments when folding gimple stmts Message-ID: <20101008204654.GS17388@nightcrawler> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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. 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)