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 via email to