From: Alan Modra <amodra@gmail.com>
To: gcc-patches@gcc.gnu.org
Cc: segher@kernel.crashing.org, Alan Modra <amodra@gmail.com>
Subject: [PATCH 7/8] [RS6000] rs6000_rtx_costs reduce cost for SETs
Date: Thu, 8 Oct 2020 09:27:59 +1030 [thread overview]
Message-ID: <20201007225800.9536-8-amodra@gmail.com> (raw)
In-Reply-To: <20201007225800.9536-1-amodra@gmail.com>
The aim of this patch is to make rtx_costs for SETs closer to
insn_cost for SETs. One visible effect on powerpc code is increased
if-conversion.
* 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 76aedbfae6f..d455aa52427 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -21684,6 +21684,35 @@ rs6000_rtx_costs (rtx x, machine_mode mode, int outer_code,
}
return false;
+ 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:
return false;
}
next prev parent reply other threads:[~2020-10-07 22:58 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-07 22:57 [PATCH 0/8] [RS6000] rs6000_rtx_costs V2 Alan Modra
2020-10-07 22:57 ` [PATCH 1/8] [RS6000] rs6000_rtx_costs comment Alan Modra
2020-10-14 20:08 ` Segher Boessenkool
2020-10-07 22:57 ` [PATCH 2/8] [RS6000] rs6000_rtx_costs for AND Alan Modra
2020-10-20 18:55 ` Segher Boessenkool
2020-10-21 2:57 ` Alan Modra
2020-10-21 20:29 ` Segher Boessenkool
2020-10-21 22:11 ` Alan Modra
2020-10-22 13:29 ` Segher Boessenkool
2020-10-23 23:18 ` Hans-Peter Nilsson
2020-10-24 1:04 ` Alan Modra
2020-10-07 22:57 ` [PATCH 3/8] [RS6000] rs6000_rtx_costs tidy AND Alan Modra
[not found] ` <20210112033157.GA26219@bubble.grove.modra.org>
2021-01-21 23:09 ` Alan Modra
2021-01-25 22:37 ` Segher Boessenkool
2021-02-01 2:06 ` Alan Modra
2020-10-07 22:57 ` [PATCH 4/8] [RS6000] rs6000_rtx_costs tidy break/return Alan Modra
[not found] ` <20210112033209.GB26219@bubble.grove.modra.org>
2021-01-21 23:09 ` Alan Modra
2021-01-25 22:40 ` Segher Boessenkool
2020-10-07 22:57 ` [PATCH 5/8] [RS6000] rs6000_rtx_costs cost IOR Alan Modra
[not found] ` <20210112033218.GC26219@bubble.grove.modra.org>
2021-01-21 23:10 ` Alan Modra
2021-01-25 22:51 ` Segher Boessenkool
2021-02-01 2:13 ` Alan Modra
2020-10-07 22:57 ` [PATCH 6/8] [RS6000] rs6000_rtx_costs multi-insn constants Alan Modra
2020-10-07 22:57 ` Alan Modra [this message]
2020-10-08 18:19 ` [PATCH 7/8] [RS6000] rs6000_rtx_costs reduce cost for SETs will schmidt
[not found] ` <20210112033227.GD26219@bubble.grove.modra.org>
2021-01-21 23:10 ` Alan Modra
2020-10-07 22:58 ` [PATCH 8/8] [RS6000] rs6000_rtx_costs for !speed Alan Modra
[not found] ` <20210112033236.GE26219@bubble.grove.modra.org>
2021-01-21 23:11 ` Alan Modra
2020-12-05 9:12 ` [PATCH 0/8] [RS6000] rs6000_rtx_costs V2 Alan Modra
2021-01-11 21:42 ` Alan Modra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201007225800.9536-8-amodra@gmail.com \
--to=amodra@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=segher@kernel.crashing.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).