From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 39666 invoked by alias); 18 May 2017 10:16:35 -0000 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 Received: (qmail 39627 invoked by uid 89); 18 May 2017 10:16:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy= X-HELO: mail-vk0-f48.google.com Received: from mail-vk0-f48.google.com (HELO mail-vk0-f48.google.com) (209.85.213.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 18 May 2017 10:16:29 +0000 Received: by mail-vk0-f48.google.com with SMTP id h16so20613979vkd.2 for ; Thu, 18 May 2017 03:16:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=/zHywR3RftqI0UXBF+/+aevLUmi1DRF0bQrlTCfq7S4=; b=Zv04aiccVSryCbsjQ3dgWI7PXis0XYO6l6+n4lSeraezXfpfI7Xr3qfd7dWgHH1VE6 J4mU7XcboU2C2Kc4d+Vn61A+lOIDCDsxw3IJmEzP8Qg+oULGyxM1IZSzmAwl/sGIDCfb RShh4ylzjTh22+PLrZNZbBvpSeW+4xth5KvKC6f31j1T++lGohQ0C7+1a53YBPJVmCVF ybwoZjhsd9KavaPIgzguoYXpA5rwsq5z9t84nVThHy1ejqHcieoC9ZVEnFaZ7NfCBvia l2LrowAGT9lI4SI58XhBKjPlyMamk875vupsxhtHZ2uxjmI7H4z2L08miVvS8tSb7tOw dTNw== X-Gm-Message-State: AODbwcCKk4vUmZ8VnPdi+NlvvufsLwEd06f3GoVT5yv2NgT/xOwx90Zb ulN2bvxVWaz6xBspw9dbffvfEkpALw== X-Received: by 10.31.169.142 with SMTP id s136mr1719812vke.126.1495102591245; Thu, 18 May 2017 03:16:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.14.1 with HTTP; Thu, 18 May 2017 03:16:30 -0700 (PDT) In-Reply-To: <87fug3bqwm.fsf@linaro.org> References: <87fug3bqwm.fsf@linaro.org> From: "Bin.Cheng" Date: Thu, 18 May 2017 10:25:00 -0000 Message-ID: Subject: Re: [PATCH GCC8][29/33]New register pressure estimation To: "Bin.Cheng" , Richard Biener , "gcc-patches@gcc.gnu.org" , Richard Sandiford Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg01443.txt.bz2 On Wed, May 17, 2017 at 1:37 PM, Richard Sandiford wrote: > "Bin.Cheng" writes: >> -/* Calculates cost for having N_REGS registers. This number includes >> - induction variables, invariant variables and invariant expressions. */ >> +/* Estimate register pressure for loop having N_INVS invariants and N_CANDS >> + induction variables. Note N_INVS includes both invariant variables and >> + invariant expressions. */ >> >> static unsigned >> -ivopts_global_cost_for_size (struct ivopts_data *data, unsigned n_regs) >> +ivopts_estimate_reg_pressure (struct ivopts_data *data, unsigned n_invs, >> + unsigned n_cands) >> { >> - unsigned cost = estimate_reg_pressure_cost (n_regs, >> - data->regs_used, data->speed, >> - data->body_includes_call); >> - /* Add n_regs to the cost, so that we prefer eliminating ivs if possible. */ >> - return n_regs + cost; >> + unsigned cost; >> + unsigned n_old = data->regs_used, n_new = n_invs + n_cands; >> + unsigned regs_needed = n_new + n_old, available_regs = target_avail_regs; >> + bool speed = data->speed; >> + >> + /* If there is a call in the loop body, the call-clobbered registers >> + are not available for loop invariants. */ >> + if (data->body_includes_call) >> + available_regs = available_regs - target_clobbered_regs; >> + >> + /* If we have enough registers. */ >> + if (regs_needed + target_res_regs < available_regs) >> + cost = n_new; >> + /* If close to running out of registers, try to preserve them. */ >> + else if (regs_needed <= available_regs) >> + cost = target_reg_cost [speed] * regs_needed; >> + /* If we run out of available registers but the number of candidates >> + does not, we penalize extra registers using target_spill_cost. */ >> + else if (n_cands <= available_regs) >> + cost = target_reg_cost [speed] * available_regs >> + + target_spill_cost [speed] * (regs_needed - available_regs); >> + /* If the number of candidates runs out available registers, we penalize >> + extra candidate registers using target_spill_cost * 2. Because it is >> + more expensive to spill induction variable than invariant. */ >> + else >> + cost = target_reg_cost [speed] * available_regs >> + + target_spill_cost [speed] * (n_cands - available_regs) * 2 >> + + target_spill_cost [speed] * (regs_needed - n_cands); >> + >> + /* Finally, add the number of candidates, so that we prefer eliminating >> + induction variables if possible. */ >> + return cost + n_cands; > > It looks like the return is mixing units. Would it work to return > a pair instead, and use lexicographical ordering? Hi Richard, It just penalizes the cost by the number of candidates, rather than returns n_cands to caller. Actually that information is available all the time in ivopts_data structure. Thanks, bin > > Thanks, > Richard