From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id F31FF3857C54 for ; Mon, 21 Sep 2020 07:08:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F31FF3857C54 Received: by mail-pf1-x42b.google.com with SMTP id k8so8481061pfk.2 for ; Mon, 21 Sep 2020 00:08:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=eDlR+sQKwGS7VyB6L9FKduwyuKnhP5gTHdW/tLuY/xE=; b=t77sgJuRlGTzUK0LqFJVHwlVcMgxrCDp9jIPxd7Xf00K9HcAhV1r1mzSeEgPE94wQG WSG+URcdZAAfiiDHRjoJX9IdVtI3S7LyJBeMs3Csyytco2dx1InQxHhtBibonQmOnzgv bpbyS6CdSbLS6ArdjWPEefd9ZGpi3TAd/3uWLtCKlKRk4O+y8iCIpmezUqDmi92dExwd ekt/+fo0HAcJ+sWbiEHBrCvys8eVYWaDyKyzOS3Xv7zjZTi7jrmwzXFbGeactkgYjCD/ Jj3lQZAzZtX5rfvzX/Sl1aDnza03CUN0ZK/QYMUlgRtxqttBt8EpB/5anSb9xAVm0aef ygkA== X-Gm-Message-State: AOAM530mfTGLBAi0k3NVysIugT2IKmzfEO9cYk1GbIiuwjhkFMRfktmA sFTV3S/nU5Vf1hDYZBTpIQn3f5qExyA= X-Google-Smtp-Source: ABdhPJxludwZqwYA/x0mW9BrlH/B/80ehdCrIx2wr/bwMaKC+c4zKMPbYOe6SNz5o++A6RSVPn2cAw== X-Received: by 2002:a63:5d09:: with SMTP id r9mr33604594pgb.397.1600672081822; Mon, 21 Sep 2020 00:08:01 -0700 (PDT) Received: from bubble.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id z28sm11748923pfq.81.2020.09.21.00.08.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 00:08:00 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 1C32785B21; Mon, 21 Sep 2020 16:37:57 +0930 (ACST) Date: Mon, 21 Sep 2020 16:37:57 +0930 From: Alan Modra To: Segher Boessenkool Cc: gcc-patches@sourceware.org Subject: Re: [RS6000] rs6000_rtx_costs reduce cost for SETs Message-ID: <20200921070756.GX5452@bubble.grove.modra.org> References: <20200915011946.3395-1-amodra@gmail.com> <20200915011946.3395-8-amodra@gmail.com> <20200917175125.GJ28786@gate.crashing.org> <20200918033842.GT5452@bubble.grove.modra.org> <20200918181318.GR28786@gate.crashing.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200918181318.GR28786@gate.crashing.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-12.4 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2020 07:08:04 -0000 On Fri, Sep 18, 2020 at 01:13:18PM -0500, Segher Boessenkool wrote: > Thanks (to both of you). Interesting! Which of these unrelated changes > does this come from? Most of the changes I saw in code generation (not in spec, I didn't look there, but in gcc) came down to this change to the cost for SETs, and "rs6000_rtx_costs multi-insn constants". I expect they were the changes that made most difference to spec results, with this patch likely resulting in more if-conversion. So here is the patch again, this time without any distracting other changes. With a further revised comment. * config/rs6000/rs6000.c (rs6000_rtx_costs): Reduce cost of SET operands. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 8969baa4dcf..2d770afd8fe 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -21599,6 +21599,35 @@ rs6000_rtx_costs (rtx x, machine_mode mode, int outer_code, } break; + case SET: + /* On entry the value in *TOTAL is the number of general purpose + regs being set, multiplied by COSTS_N_INSNS (1). Handle + costing of set operands specially since in most cases we have + an instruction rather than just a piece of RTL and should + return a cost comparable to insn_cost. That's a little + complicated because in some cases the cost of SET operands is + non-zero, see point 5 above and cost of PLUS for example, and + in others it is zero, for example for (set (reg) (reg)). + But (set (reg) (reg)) has the same insn_cost as + (set (reg) (plus (reg) (reg))). Hack around this by + subtracting COSTS_N_INSNS (1) from the operand cost in cases + were we add at least COSTS_N_INSNS (1) for some operation. + However, don't do so for constants. Constants might cost + more than zero when they require more than one instruction, + and we do want the cost of extra instructions. */ + { + rtx_code src_code = GET_CODE (SET_SRC (x)); + if (src_code == CONST_INT + || src_code == CONST_DOUBLE + || src_code == CONST_WIDE_INT) + return false; + int set_cost = (rtx_cost (SET_SRC (x), mode, SET, 1, speed) + + rtx_cost (SET_DEST (x), mode, SET, 0, speed)); + if (set_cost >= COSTS_N_INSNS (1)) + *total += set_cost - COSTS_N_INSNS (1); + return true; + } + default: break; } -- Alan Modra Australia Development Lab, IBM