From patchwork Thu Jun 19 16:06:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 361916 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7C27514008B for ; Fri, 20 Jun 2014 02:06:21 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=KOL/9uvrkGVOLCs7A IPEY9wbOvEkrJe3qbS9gdHtrDFsg02hq4RpReeV0Mu7Cfhsv6eUJ8ad+uYgiUSEK Z6nFCQgoQxTs0BrZGZa8lIjHzzekyG6xNwwCehAr2WZJGpaDUKiurWa2SMqTNwTH lDyGKgIlgxXPy11Vd50qswDnco= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=kq8ZvR6aL8ox4edpb+OXg2j 3rjw=; b=G9ysiMy3RHnW/lMO6vcmCx+cYtWgjhr7ni8HNnFsm5Qg8IDRNkv4NGA sMftVZSi921sozVDVBPpkZAEH2N7U+08k6wG7UMvCg2nJWkG9gkmzUO/ImRHJWh5 +ctgMadqYVtXbVO6MyHYYuepP5i31Es+6VrqJ+o/sYhCK0eO+afI= Received: (qmail 27683 invoked by alias); 19 Jun 2014 16:06:14 -0000 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 Received: (qmail 27672 invoked by uid 89); 19 Jun 2014 16:06:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 19 Jun 2014 16:06:12 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1Wxeqk-00079H-Gn from Tom_deVries@mentor.com ; Thu, 19 Jun 2014 09:06:06 -0700 Received: from SVR-IES-FEM-02.mgc.mentorg.com ([137.202.0.106]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 19 Jun 2014 09:06:06 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.2.247.3; Thu, 19 Jun 2014 17:06:05 +0100 Message-ID: <53A30A69.7060905@mentor.com> Date: Thu, 19 Jun 2014 18:06:01 +0200 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Richard Henderson CC: Eric Botcazou , , Jan Hubicka , Subject: Re: -fuse-caller-save - Collect register usage information References: <534ED7BC.50300@mentor.com> <878uqwgjoe.fsf@talisman.default> <535BABD1.8050208@mentor.com> <1426417.RtLpSRnsYv@polaris> <537A1583.7020702@mentor.com> <53A27162.7070208@redhat.com> In-Reply-To: <53A27162.7070208@redhat.com> On 19-06-14 07:13, Richard Henderson wrote: > On 05/19/2014 07:30 AM, Tom de Vries wrote: >> + for (insn = get_insns (); insn != NULL_RTX; insn = next_insn (insn)) >> + { >> + HARD_REG_SET insn_used_regs; >> + >> + if (!NONDEBUG_INSN_P (insn)) >> + continue; >> + >> + find_all_hard_reg_sets (insn, &insn_used_regs, false); >> + >> + if (CALL_P (insn) >> + && !get_call_reg_set_usage (insn, &insn_used_regs, call_used_reg_set)) >> + { >> + CLEAR_HARD_REG_SET (node->function_used_regs); >> + return; >> + } >> + >> + IOR_HARD_REG_SET (node->function_used_regs, insn_used_regs); >> + } > Let's suppose that we've got a rather large function, with only local calls for > which we can acquire usage. Let's suppose that even one of those callees > further calls something else, such that insn_used_regs == call_used_reg_set. > > We fill node->function_used_regs immediately, but keep scanning the rest of the > large function. > > >> + >> + /* Be conservative - mark fixed and global registers as used. */ >> + IOR_HARD_REG_SET (node->function_used_regs, fixed_reg_set); >> + for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) >> + if (global_regs[i]) >> + SET_HARD_REG_BIT (node->function_used_regs, i); >> + >> +#ifdef STACK_REGS >> + /* Handle STACK_REGS conservatively, since the df-framework does not >> + provide accurate information for them. */ >> + >> + for (i = FIRST_STACK_REG; i <= LAST_STACK_REG; i++) >> + SET_HARD_REG_BIT (node->function_used_regs, i); >> +#endif >> + >> + node->function_used_regs_valid = 1; > > Wouldn't it be better to compare the collected function_used_regs; if it > contains all of call_used_reg_set, decline to set function_used_regs_valid. > That way, we'll early exit from the above loop whenever we see that we can't > improve over the default call-clobber set. > Richard, Agreed. Attached patch implements this (on top of the minor rewrite of https://gcc.gnu.org/ml/gcc-patches/2014-06/msg01535.html ). > Although perhaps function_used_regs_valid is no longer the best name in that > case... > I think the name is still ok. The field function_used_regs_valid just states that the function_used_regs field is valid and can be used. OK for trunk if bootstrap and reg-test on x86_64 is ok ? Thanks, - Tom 2014-06-19 Tom de Vries * final.c (collect_fn_hard_reg_usage): Don't save function_used_regs if it contains all call_used_regs. diff --git a/gcc/final.c b/gcc/final.c index e39930d..e67e84b 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -4795,6 +4795,11 @@ collect_fn_hard_reg_usage (void) SET_HARD_REG_BIT (function_used_regs, i); #endif + /* The information we have gathered is only interesting if it exposes a + register from the call_used_regs that is not used in this function. */ + if (hard_reg_set_subset_p (call_used_reg_set, function_used_regs)) + return; + node = cgraph_rtl_info (current_function_decl); gcc_assert (node != NULL); -- 1.9.1