From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6767 invoked by alias); 1 Oct 2009 08:49:57 -0000 Received: (qmail 6729 invoked by uid 22791); 1 Oct 2009 08:49:56 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from nikam-dmz.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 01 Oct 2009 08:49:50 +0000 Received: from localhost (campfire.ms.mff.cuni.cz [195.113.18.99]) by nikam.ms.mff.cuni.cz (Postfix) with ESMTP id E654015384F; Thu, 1 Oct 2009 10:50:15 +0200 (CEST) Received: by localhost (Postfix, from userid 29025) id 0E0E5E33E5; Thu, 1 Oct 2009 10:49:48 +0200 (CEST) Date: Thu, 01 Oct 2009 08:49:00 -0000 From: Zdenek Dvorak To: Vladimir Makarov Cc: gcc-patches Subject: Re: Ping: IRA-based register pressure calculation for RTL loop invariant motion Message-ID: <20091001084947.GA5640@kam.mff.cuni.cz> References: <4AC41EE0.8010000@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4AC41EE0.8010000@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2009-10/txt/msg00019.txt.bz2 Hi, > The patch was posted on > > http://gcc.gnu.org/ml/gcc-patches/2009-09/msg01889.html in gain_for_invariant: > + for (i = 0; i < ira_reg_class_cover_size; i++) > + { > + cover_class = ira_reg_class_cover[i]; > + if ((diff = ((int) new_regs[cover_class] > + + (int) regs_needed[cover_class] > + + LOOP_DATA (curr_loop)->max_reg_pressure[cover_class] > + + IRA_LOOP_RESERVED_REGS > + - ira_available_class_regs[cover_class])) > 0) > + break; > + } diff is not used. > + if (i < ira_reg_class_cover_size) > + size_cost = comp_cost + 10; > + else > + size_cost = 0; Including comp_cost in size_cost makes no sense (this would prevent us from moving even very costly invariants out of the loop if we run out of registers). Also, the magic constant 10 requires some explanation (especially since the costs elsewhere in the invariant motion are expressed in terms of the costs of basic operations as reported by rtx_cost, so using an absolute constant will have different effects on different architectures, depending on the arbitrary choice of the instruction cost scale). > + fprintf (dump_file, "Decided to move dependet invariant %d\n", > + invno); dependent > @@ -1154,7 +1297,8 @@ find_invariants_to_move (bool speed) > /* We do not really do a good job in estimating number of registers used; > we put some initial bound here to stand for induction variables etc. > that we do not detect. */ > - regs_used = 2; > + if (! flag_ira_loop_pressure) > + regs_used = 2; > > for (i = 0; i < n_regs; i++) > { If flag_ira_loop_pressure is true, regs_used is used uninitialized in the following loop (you should be getting uninitialized variable warning on this). The loop should be guarded by !flag_ira_loop_pressure as well. > - new_regs = 0; > - while (best_gain_for_invariant (&inv, ®s_needed, new_regs, regs_used, speed) > 0) > + if (! flag_ira_loop_pressure) > + new_regs[0] = regs_needed[0] = 0; > + else > { > - set_move_mark (inv->invno); > - new_regs += regs_needed; > + for (i = 0; (int) i < ira_reg_class_cover_size; i++) > + { > + new_regs[ira_reg_class_cover[i]] = 0; > + regs_needed[ira_reg_class_cover[i]] = 0; > + } > + } It should not be necessary to zero the regs_needed array. > +DEFPARAM (PARAM_IRA_LOOP_RESERVED_REGS, > + "ira-loop-reserved-regs", > + "The number of registers reserved for loop invariant motion", > + 2, 0, 0) "The number of registers in each class kept unused by loop invariant motion" would seem like a better description. Zdenek