public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "vmakarov at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/114766] ^ constraint modifier unexpectedly affects register class selection.
Date: Fri, 19 Apr 2024 22:04:18 +0000	[thread overview]
Message-ID: <bug-114766-4-3UbvJjqtI3@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114766-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114766

--- Comment #1 from Vladimir Makarov <vmakarov at gcc dot gnu.org> ---
(In reply to Tamar Christina from comment #0)
> The documentation for ^ states:
> 
> "This constraint is analogous to ‘?’ but it disparages slightly the
> alternative only if the operand with the ‘^’ needs a reload."
> 
> 
> The penalty here seems incorrect, and removing it seems to get the
> constraint to work properly.
> So the question is, is it a bug, or are we using it incorrectly? or a
> documentation bug?

The current behavior of '^' is how it was originally planned. 

With this point of view I would say that it is a documentation ambiguity. 
documentation of '?' also does not clearly say about its affect on the cost
calculation and as a consequence on choosing register class.

On the other hand, I don't know what is really needed.  If you need what you
expected, please try the following patch:

diff --git a/gcc/ira-costs.cc b/gcc/ira-costs.cc
index c86c5a16563..04d2f21b023 100644
--- a/gcc/ira-costs.cc
+++ b/gcc/ira-costs.cc
@@ -771,10 +771,6 @@ record_reg_classes (int n_alts, int n_ops, rtx *ops,
                  c = *++p;
                  break;

-               case '^':
-                 alt_cost += 2;
-                 break;
-
                case '?':
                  alt_cost += 2;
                  break;

If it works for you, we could try to use the patch (although it needs some
investigation how other targets uses the hint).  In any case, the documentation
should be modified or made more clear depending on applying or not applying the
patch.

  reply	other threads:[~2024-04-19 22:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-18 12:01 [Bug rtl-optimization/114766] New: " tnfchris at gcc dot gnu.org
2024-04-19 22:04 ` vmakarov at gcc dot gnu.org [this message]
2024-04-20 15:24 ` [Bug rtl-optimization/114766] " tnfchris at gcc dot gnu.org
2024-04-24 12:38 ` vmakarov at gcc dot gnu.org

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=bug-114766-4-3UbvJjqtI3@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.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).