public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: gcc-patches@gcc.gnu.org
Cc: segher@kernel.crashing.org, Alan Modra <amodra@gmail.com>
Subject: [PATCH 1/8] [RS6000] rs6000_rtx_costs comment
Date: Thu,  8 Oct 2020 09:27:53 +1030	[thread overview]
Message-ID: <20201007225800.9536-2-amodra@gmail.com> (raw)
In-Reply-To: <20201007225800.9536-1-amodra@gmail.com>

This lays out the ground rules for following patches.

	* config/rs6000/rs6000.c (rs6000_rtx_costs): Expand comment.

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index b58eeae2b98..97180bb3819 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -21208,7 +21208,46 @@ rs6000_cannot_copy_insn_p (rtx_insn *insn)
 
 /* Compute a (partial) cost for rtx X.  Return true if the complete
    cost has been computed, and false if subexpressions should be
-   scanned.  In either case, *TOTAL contains the cost result.  */
+   scanned.  In either case, *TOTAL contains the cost result.
+
+   1) Calls from places like optabs.c:avoid_expensive_constant will
+   come here with OUTER_CODE set to an operation such as AND with X
+   being a CONST_INT or other CONSTANT_P type.  This will be compared
+   against set_src_cost, where we'll come here with OUTER_CODE as SET
+   and X the same constant.
+
+   2) Calls from places like combine.c:distribute_and_simplify_rtx are
+   asking whether a possibly quite complex SET_SRC can be implemented
+   more cheaply than some other logically equivalent SET_SRC.
+
+   3) Calls from places like ifcvt.c:default_noce_conversion_profitable_p
+   will come here via seq_cost which calls set_rtx_cost on single set
+   insns.  set_rtx_cost passes the pattern of a SET insn in X with
+   OUTER_CODE as INSN.  The overall cost should be comparable to
+   rs6000_insn_cost since the code is comparing one insn sequence
+   (some of which may be costed by insn_cost) against another sequence.
+   Note the difference between set_rtx_cost, which costs the entire
+   SET, and set_src_cost, which costs just the SET_SRC.
+
+   4) Calls from places like cprop.c:try_replace_reg will also come
+   here via set_rtx_cost, with X either a valid pattern of a SET or
+   one where some registers have been replaced with constants.  The
+   replacements may make the SET invalid, for example if
+     (set (reg1) (and (reg2) (const_int 0xfff)))
+   has reg2 replaced as
+     (set (reg1) (and (symbol_ref) (const_int 0xfff)))
+   then the replacement can't be implemented in one instruction and
+   really the cost should be higher by one instruction.  However,
+   the cost for invalid insns doesn't matter much except that a
+   higher cost may lead to their rejection earlier.
+
+   5) fwprop.c:should_replace_address puts yet another wrinkle on this
+   function, where we prefer an address calculation that is more
+   complex yet has the same address_cost.  In this case "more
+   complex" is determined by having a higher set_src_cost.  So for
+   example, if we want a plain (reg) address to be replaced with
+   (plus (reg) (const)) when possible then PLUS needs to cost more
+   than zero here.  */
 
 static bool
 rs6000_rtx_costs (rtx x, machine_mode mode, int outer_code,

  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 ` Alan Modra [this message]
2020-10-14 20:08   ` [PATCH 1/8] [RS6000] rs6000_rtx_costs comment 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 ` [PATCH 7/8] [RS6000] rs6000_rtx_costs reduce cost for SETs Alan Modra
2020-10-08 18:19   ` 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-2-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).