From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28599 invoked by alias); 26 Aug 2004 05:45:41 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 28576 invoked from network); 26 Aug 2004 05:45:36 -0000 Received: from unknown (HELO mproxy.gmail.com) (64.233.170.199) by sourceware.org with SMTP; 26 Aug 2004 05:45:36 -0000 Received: by mproxy.gmail.com with SMTP id 77so166572rnl for ; Wed, 25 Aug 2004 22:45:32 -0700 (PDT) Received: by 10.38.70.46 with SMTP id s46mr2342415rna; Wed, 25 Aug 2004 22:45:32 -0700 (PDT) Received: by 10.38.79.78 with HTTP; Wed, 25 Aug 2004 22:45:32 -0700 (PDT) Message-ID: Date: Thu, 26 Aug 2004 09:04:00 -0000 From: Qiong Cai Reply-To: Qiong Cai To: James E Wilson Subject: Re: number of spills and reloads Cc: gcc@gcc.gnu.org In-Reply-To: <412D1F08.20307@specifixinc.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <412D1F08.20307@specifixinc.com> X-SW-Source: 2004-08/txt/msg01314.txt.bz2 Hi James, Thanks for the reply. > find_reload_regs gets called once for every instruction that needs a > reload. find_reg gets called once for every operand of every > instruction that needs a spill register allocated to satisfy a reload. > But we only reach the place where we emit the message if we choose to > allocate a new spill register. I'm a bit confused with "spill register". Consider the following example, r0 <- [sp+4] + [sp + 8] then operand 1 must be the register. so reload into register r1 first r1 <- [sp+4] Is the register r1 a "spill" register? > > Counting the instructions that need a reload is a very poor measure of > the number of spills. There is n_spills which counts the number of hard > registers allocated for use as spill registers which is one reasonable > measure. n_spills is probably very close to your num_reloads. The > different is probably eliminable registers like the frame pointer. > Another measure might be the number of pseudos that get forced to stack > slots in order to free up hard registers for use as spill registers. > This can be computed by counting the number of registers in spilled_pseudos. > I need the number of "stores" or "spills" to memory caused by register allocation. It seems that this is close to your second measure. Also I'd like to know the dyanmic counts of "stores". For example, x = a + b [ dynamic count = 10000 from edge profiling] If the pseduos "a" and "b" must be forced to stack: [sp + 4] <- a [sp + b] <- b So the dyanmic count is 10000+10000 = 20000. Is this the reasonable measure of dynamic counts of "stores" or "spills" introduced by register allocation? > For the number of reloads, there is n_reloads computed by find_reloads. > This is a per instruction count. You would have to sum it over all > instructions to get a count for the entire function. But there are a > number of ambiguities here. > > We sometimes create what is known as "optional" reloads. These are > things that don't need a reload, but might result in better code if they > do get a reload. Sometimes we perform them. Sometimes we don't. You > may or not want to count them. > > We also have secondary reloads. Sometimes a single reload needs two > registers, which we handle by creating two reloads, one of which is a > secondary reload. So is that 1 reload or 2? Depends on how you want to > count them. > > Some reloads need a spill register, some don't. If a reload can never > result in a spill, do you still want to count it? > > Some reloads involve multi-word values which may require multiple spill > registers. Where's the place in which the final reload is emitted? If I know the place, then I just count the number of reload there. -- Qiong Cai www.cse.unsw.edu.au/~qiongc