From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id 25F7C3857404 for ; Fri, 28 Oct 2022 07:38:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 25F7C3857404 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x533.google.com with SMTP id 21so6694775edv.3 for ; Fri, 28 Oct 2022 00:38:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Rs8vBjGCwKiybGHqGvn6WpaAf0YIbDpLJLti+UWMeR0=; b=osjsw2SgcpD6/48lxucvQ/aqOAjDGbpYNifF306HJ52PRK5ge5/BRHa1EMWtF1Hoa3 jgEYrXw/azWYDhrkVK+Qb4n/ceatfI/Pc0L2K54A3T8t9scBDyLtAEGBVEeKYaTcQkUl V9YR+pno2m4f5geKCl2OMan2jBOj1VVTiYrBgsxL4LVzdekuBy7VeF3InyJKGTPfb3p0 G8zbdIReKRp/aEkuI/0/PU5D4UVYmis+LMD6sqzSUasUBpTFDe18Ok7vg28IPRtuk8t9 nimCIaUxWJx5gDofkGMhIJ8snfpxIjI2sT69mjNudb+uMR1k/1g1SAVbkVXF8t1YAerG txxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Rs8vBjGCwKiybGHqGvn6WpaAf0YIbDpLJLti+UWMeR0=; b=SfPPQTYv2L1VMGLAsnSmZ6k3C2qjViZ3Piq97EL1r3MVNhgXdc1jjd8JQ2urXfXXMw 6VZWhnAvJffJpTtgc2gBPddl1TJPBfaBgOWpLjcIOELYg9Qrwz6Jzb4LwFUOI0YezdyN uhNBbd2uifJhDhGXdUDlQgRBaC6TH6NEU/aH6t1Qsu3NaaUYSfxptIz8hrRNFUGDiMyV M1tH7PgSAZTh9WyDknLV8IOy+uW8ow1WYeWsGao6Tk5+qLhPyBAzdxKe1KO5nA3XBatr h9RGQtcXvsjgvI2YWdP4c9pFiPY3tZCjBJaFyNThE7HyFMuLo7QNmkb9Ro0a2SBSAzri V1jw== X-Gm-Message-State: ACrzQf3SMzbg8wkkQJ+DURkl9D1oVO923VRuka0lVzETLOO/u1vZwbe6 hXg4D6hDU0AF+OPx+oN9BC/aBzKxQODhinCQG0o= X-Google-Smtp-Source: AMsMyM5UMVGaFbD+Y83c4zjc5PJM2T9zi5wKzA242kc5x3vgpdeTDD5LFjBTERHd/Bz6HvcvueGnhjdPNoav8YPK/qA= X-Received: by 2002:aa7:d8c4:0:b0:461:8d31:41fc with SMTP id k4-20020aa7d8c4000000b004618d3141fcmr28572492eds.202.1666942713919; Fri, 28 Oct 2022 00:38:33 -0700 (PDT) MIME-Version: 1.0 References: <20221021135203.626255-1-dimitrije.milosevic@syrmia.com> <20221021135203.626255-3-dimitrije.milosevic@syrmia.com> In-Reply-To: From: Richard Biener Date: Fri, 28 Oct 2022 09:38:21 +0200 Message-ID: Subject: Re: [PATCH 2/2] ivopts: Consider number of invariants when calculating register pressure. To: Dimitrije Milosevic Cc: "gcc-patches@gcc.gnu.org" , Djordje Todorovic Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, Oct 25, 2022 at 3:00 PM Dimitrije Milosevic wrote: > > Hi Richard, > > > don't you add n_invs twice now given > > > > unsigned n_old =3D data->regs_used, n_new =3D n_invs + n_cands; > > unsigned regs_needed =3D n_new + n_old, available_regs =3D target_avai= l_regs; > > > > ? > > If you are referring to the "If we have enough registers." case, correct.= After c18101f, > for that case, the returned cost is equal to 2 * n_invs + n_cands. It's n_invs + 2 * n_cands? And the comment states the reasoning. Before c18101f, for > that case, the returned cost is equal to n_invs + n_cands. Another soluti= on would be > to just return n_invs + n_cands if we have enough registers. The comment says we want to prefer eliminating IVs over invariants. Your p= atch undoes that by weighting invariants the same so it does no longer have the effect of the comment. > Regards, > Dimitrije > > > From: Richard Biener > Sent: Tuesday, October 25, 2022 1:07 PM > To: Dimitrije Milosevic > Cc: gcc-patches@gcc.gnu.org ; Djordje Todorovic = > Subject: Re: [PATCH 2/2] ivopts: Consider number of invariants when calcu= lating register pressure. > > On Fri, Oct 21, 2022 at 3:57 PM Dimitrije Milosevic > wrote: > > > > From: Dimitrije Milo=C5=A1evi=C4=87 > > > > This patch slightly modifies register pressure model function to consid= er > > both the number of invariants and the number of candidates, rather than > > just the number of candidates. This used to be the case before c18101f. > > don't you add n_invs twice now given > > unsigned n_old =3D data->regs_used, n_new =3D n_invs + n_cands; > unsigned regs_needed =3D n_new + n_old, available_regs =3D target_avail= _regs; > > ? > > > gcc/ChangeLog: > > > > * tree-ssa-loop-ivopts.cc (ivopts_estimate_reg_pressure): Adjus= t. > > > > Signed-off-by: Dimitrije Milosevic > > --- > > gcc/tree-ssa-loop-ivopts.cc | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/gcc/tree-ssa-loop-ivopts.cc b/gcc/tree-ssa-loop-ivopts.cc > > index d53ba05a4f6..9d0b669d671 100644 > > --- a/gcc/tree-ssa-loop-ivopts.cc > > +++ b/gcc/tree-ssa-loop-ivopts.cc > > @@ -6409,9 +6409,9 @@ ivopts_estimate_reg_pressure (struct ivopts_data = *data, unsigned n_invs, > > + 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 eliminat= ing > > - induction variables if possible. */ > > - return cost + n_cands; > > + /* Finally, add the number of invariants and the number of candidate= s, > > + so that we prefer eliminating induction variables if possible. *= / > > + return cost + n_invs + n_cands; > > } > > > > /* For each size of the induction variable set determine the penalty. = */ > > -- > > 2.25.1 > >