public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Dimitrije Milošević" <dimitrije.milosevic@syrmia.com>
To: gcc-patches@gcc.gnu.org
Cc: djordje.todorovic@syrmia.com, richard.guenther@gmail.com,
	jeffreyalaw@gmail.com,
	"Dimitrije Milošević" <dimitrije.milosevic@syrmia.com>
Subject: [PATCH 1/2] ivopts: Compute complexity for unsupported addressing modes.
Date: Wed, 21 Dec 2022 14:12:13 +0100	[thread overview]
Message-ID: <20221221131214.190579-2-dimitrije.milosevic@syrmia.com> (raw)
In-Reply-To: <20221221131214.190579-1-dimitrije.milosevic@syrmia.com>

After f9f69dd, complexity is calculated using the
valid_mem_ref_p target hook. Architectures like Mips only
allow BASE + OFFSET addressing modes, which in turn prevents
the calculation of complexity for other addressing modes,
resulting in non-optimal candidate selection.

There still is code that adjusts the address cost for
unsupported addressing modes, however, it only adjusts the
cost part (the complexity part is left at 0).

gcc/ChangeLog:

	* tree-ssa-loop-ivopts.cc (get_address_cost): Calculate
	complexity for unsupported addressing modes as well.

Signed-off-by: Dimitrije Milosevic <dimitrije.milosevic@syrmia.com>
---
 gcc/tree-ssa-loop-ivopts.cc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-ssa-loop-ivopts.cc b/gcc/tree-ssa-loop-ivopts.cc
index ebd4aecce37..60c61dc9e49 100644
--- a/gcc/tree-ssa-loop-ivopts.cc
+++ b/gcc/tree-ssa-loop-ivopts.cc
@@ -4778,10 +4778,14 @@ get_address_cost (struct ivopts_data *data, struct iv_use *use,
     comp_inv = aff_combination_to_tree (aff_inv);
   if (comp_inv != NULL_TREE)
     cost = force_var_cost (data, comp_inv, inv_vars);
-  if (ratio != 1 && parts.step == NULL_TREE)
+  if (ratio != 1 && parts.step == NULL_TREE) {
     var_cost += mult_by_coeff_cost (ratio, addr_mode, speed);
-  if (comp_inv != NULL_TREE && parts.index == NULL_TREE)
+    var_cost.complexity += 1;
+  }
+  if (comp_inv != NULL_TREE && parts.index == NULL_TREE) {
     var_cost += add_cost (speed, addr_mode);
+    var_cost.complexity += 1;
+  }
 
   if (comp_inv && inv_expr && !simple_inv)
     {
-- 
2.25.1


  reply	other threads:[~2022-12-21 13:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-21 13:12 [PATCH 0/2]: Fix address cost complexity and register pressure cost calculation Dimitrije Milošević
2022-12-21 13:12 ` Dimitrije Milošević [this message]
2022-12-21 13:12 ` [PATCH 2/2] ivopts: Revert register pressure cost when there are enough registers Dimitrije Milošević
2023-05-15 10:44   ` Richard Biener
2023-05-15 12:23     ` Richard Biener
2023-05-15 14:32       ` Jovan Dmitrovic

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=20221221131214.190579-2-dimitrije.milosevic@syrmia.com \
    --to=dimitrije.milosevic@syrmia.com \
    --cc=djordje.todorovic@syrmia.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jeffreyalaw@gmail.com \
    --cc=richard.guenther@gmail.com \
    /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).