From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21439 invoked by alias); 31 Aug 2004 00:14:10 -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 21431 invoked from network); 31 Aug 2004 00:14:09 -0000 Received: from unknown (HELO bluesmobile.specifixinc.com) (64.220.152.98) by sourceware.org with SMTP; 31 Aug 2004 00:14:09 -0000 Received: from [127.0.0.1] (unknown [192.168.1.2]) by bluesmobile.specifixinc.com (Postfix) with ESMTP id AB10116399; Mon, 30 Aug 2004 17:14:08 -0700 (PDT) Subject: Re: number of spills and reloads From: James E Wilson To: Qiong Cai Cc: gcc@gcc.gnu.org In-Reply-To: References: <412D1F08.20307@specifixinc.com> Content-Type: text/plain Message-Id: <1093911248.7528.44.camel@aretha.corp.specifixinc.com> Mime-Version: 1.0 Date: Tue, 31 Aug 2004 00:48:00 -0000 Content-Transfer-Encoding: 7bit X-SW-Source: 2004-08/txt/msg01554.txt.bz2 On Wed, 2004-08-25 at 22:45, Qiong Cai wrote: > 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? A spill register is an allocatable register that the reload pass can use for resolving reloads. Preferably this is a register that wasn't used by the local or global register allocation passes. But if we need a reg, and there isn't one free, we can make one free by picking a hard reg, and then for every pseudo reg allocated to that hard reg, we spill it to the stack. Since this is expensive, the reload pass tries to compute the minimum number of spill regs needed. For your example, yes, in the common case, r1 will be a spill reg. However, it isn't guaranteed to be a spill reg. There is quite a bit of complexity in reload to try to avoid using a spill reg when we don't need one, so in complicated cases we might be able to reuse a register from elsewhere. For instance, if the previous instruction was [sp+4] <- r1 then we will use r1 instead of a spill reg. (Though of course, r1 could itself be a spill reg if the previous instruction needed a spill reg.) > I need the number of "stores" or "spills" to memory caused by register > allocation. > It seems that this is close to your second measure. There are actually two things here. There are pseudos which get assigned to a hard reg in local/global, and then spilled to the stack in reload. And there are pseudos which never get assigned to a hard reg. You may have to count these separately, as they may be handled in different places. A pseudo may be used in more than one place, which means you have to find all of the places where they are used. Reload doesn't track this info because it doesn't need to know. We modify a REG to a MEM in place, so there is no need to know where all of the uses are. It just needs to know that every instruction is fixed. It doesn't need to know how many uses there are of each pseudo. You might need a separate scan over all of the instructions to compute this. Then of course you need the dynamic count calculation for every use of a pseudo. > 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. reload_as_needed. It calls find_reloads to compute the number of reloads needed for each instruction, and then emit_reload_insns to emit the instructions needed to perform the reloads. -- Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com