From patchwork Mon Sep 26 14:00:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 116426 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 618AFB6F75 for ; Tue, 27 Sep 2011 00:00:38 +1000 (EST) Received: (qmail 26590 invoked by alias); 26 Sep 2011 14:00:29 -0000 Received: (qmail 26574 invoked by uid 22791); 26 Sep 2011 14:00:28 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-yx0-f175.google.com (HELO mail-yx0-f175.google.com) (209.85.213.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 26 Sep 2011 14:00:13 +0000 Received: by yxj17 with SMTP id 17so4760074yxj.20 for ; Mon, 26 Sep 2011 07:00:12 -0700 (PDT) Received: by 10.101.96.9 with SMTP id y9mr5876325anl.31.1317045612653; Mon, 26 Sep 2011 07:00:12 -0700 (PDT) Received: from bubble.grove.modra.org ([115.187.252.19]) by mx.google.com with ESMTPS id g38sm24087543ann.4.2011.09.26.07.00.09 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 26 Sep 2011 07:00:12 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 7212F170C2BC; Mon, 26 Sep 2011 23:30:05 +0930 (CST) Date: Mon, 26 Sep 2011 23:30:05 +0930 From: Alan Modra To: Bernd Schmidt , Peter Bergner , gcc-patches@gcc.gnu.org Subject: [PATCH] PowerPC shrink-wrap support benchmark gains Message-ID: <20110926140005.GK10321@bubble.grove.modra.org> Mail-Followup-To: Bernd Schmidt , Peter Bergner , gcc-patches@gcc.gnu.org References: <20110917071643.GT10321@bubble.grove.modra.org> <4E749FFD.8030507@codesourcery.com> <20110919001656.GZ10321@bubble.grove.modra.org> <4E77319B.4030809@codesourcery.com> <20110921152851.GE10321@bubble.grove.modra.org> <20110922144017.GF10321@bubble.grove.modra.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110922144017.GF10321@bubble.grove.modra.org> 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 This patch increases opportunities for shrink-wrapping. With this applied, http://gcc.gnu.org/ml/gcc-patches/2011-09/msg00754.html and http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01499.html plus the fix mentioned in http://gcc.gnu.org/ml/gcc-patches/2011-09/msg01016.html, along with my powerpc changes, I finally see some gains in CPU2006. 453.povray gives a massive 12% gain in one particular setup, with other benchmarks in the suite mostly showing small improvements. Some of this gain is likely due to having an extra gpr to play with before we start saving regs. * gcc/ifcvt.c (dead_or_predicable): Disable if-conversion when doing so is likely to kill a shrink-wrapping opportunity. diff -urp -x'*~' -x'*.orig' -x'*.rej' -x.svn gcc-alanshrink1/gcc/ifcvt.c gcc-current/gcc/ifcvt.c --- gcc-alanshrink1/gcc/ifcvt.c 2011-09-26 15:29:14.000000000 +0930 +++ gcc-current/gcc/ifcvt.c 2011-09-26 14:24:53.000000000 +0930 @@ -4138,6 +4138,64 @@ dead_or_predicable (basic_block test_bb, FOR_BB_INSNS (merge_bb, insn) if (NONDEBUG_INSN_P (insn)) df_simulate_find_defs (insn, merge_set); + + /* If shrink-wrapping, disable this optimization when test_bb is + the first basic block and merge_bb exits. The idea is to not + move code setting up a return register as that may clobber a + register used to pass function parameters, which then must be + saved in caller-saved regs. A caller-saved reg requires the + prologue, killing a shrink-wrap opportunity. */ + if ((flag_shrink_wrap && !epilogue_completed) + && ENTRY_BLOCK_PTR->next_bb == test_bb + && single_succ_p (new_dest) + && single_succ (new_dest) == EXIT_BLOCK_PTR + && bitmap_intersect_p (df_get_live_in (new_dest), merge_set)) + { + regset return_regs; + unsigned int i; + + return_regs = BITMAP_ALLOC (®_obstack); + + /* Start off with the intersection of regs used to pass + params and regs used to return values. */ + for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) + if (FUNCTION_ARG_REGNO_P (i) + && FUNCTION_VALUE_REGNO_P (i)) + bitmap_set_bit (return_regs, INCOMING_REGNO (i)); + + bitmap_and_into (return_regs, df_get_live_out (ENTRY_BLOCK_PTR)); + bitmap_and_into (return_regs, df_get_live_in (EXIT_BLOCK_PTR)); + if (!bitmap_empty_p (return_regs)) + { + FOR_BB_INSNS_REVERSE (new_dest, insn) + if (NONDEBUG_INSN_P (insn)) + { + df_ref *def_rec; + unsigned int uid = INSN_UID (insn); + + /* If this insn sets any reg in return_regs.. */ + for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++) + { + df_ref def = *def_rec; + unsigned r = DF_REF_REGNO (def); + + if (bitmap_bit_p (return_regs, r)) + break; + } + /* ..then add all reg uses to the set of regs + we're interested in. */ + if (*def_rec) + df_simulate_uses (insn, return_regs); + } + if (bitmap_intersect_p (merge_set, return_regs)) + { + BITMAP_FREE (return_regs); + BITMAP_FREE (merge_set); + return FALSE; + } + } + BITMAP_FREE (return_regs); + } } no_body: