public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug inline-asm/98096] New: Inconsistent operand numbering for asm goto with in-out operands
@ 2020-12-02 13:43 jwjagersma at gmail dot com
  2020-12-02 23:37 ` [Bug inline-asm/98096] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: jwjagersma at gmail dot com @ 2020-12-02 13:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98096
           Summary: Inconsistent operand numbering for asm goto with
                    in-out operands
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: inline-asm
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jwjagersma at gmail dot com
  Target Milestone: ---

For the following code:

    asm goto ("# %0 %1 %2" : "+r" (i) ::: jmp);

Two registers are printed before the label name, because the in-out operand is
split internally.  This is somewhat surprising from a user perspective.

But then:

    asm goto ("# %l[jmp]" : "+r" (i) ::: jmp);

Produces an error: '%l' operand isn't a label.

So label operands are numbered after the in-out operand is split, but %l is
evaluated without this split taken into account.  Docs suggest it should be
possible to use asm goto with both in-outs and %l operands simultaneously.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug inline-asm/98096] Inconsistent operand numbering for asm goto with in-out operands
  2020-12-02 13:43 [Bug inline-asm/98096] New: Inconsistent operand numbering for asm goto with in-out operands jwjagersma at gmail dot com
@ 2020-12-02 23:37 ` pinskia at gcc dot gnu.org
  2021-02-16 15:30 ` cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-12-02 23:37 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vmakarov at gcc dot gnu.org
           Keywords|                            |diagnostic, documentation

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This only matters now because output for assembly goto was only added for GCC
11.
Which was introduced with:
https://gcc.gnu.org/pipermail/gcc-patches/2020-November/558870.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug inline-asm/98096] Inconsistent operand numbering for asm goto with in-out operands
  2020-12-02 13:43 [Bug inline-asm/98096] New: Inconsistent operand numbering for asm goto with in-out operands jwjagersma at gmail dot com
  2020-12-02 23:37 ` [Bug inline-asm/98096] " pinskia at gcc dot gnu.org
@ 2021-02-16 15:30 ` cvs-commit at gcc dot gnu.org
  2021-09-14  7:48 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-16 15:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Vladimir Makarov <vmakarov@gcc.gnu.org>:

https://gcc.gnu.org/g:72d78655a91bb2f89ac4432cfd6374380d6f9987

commit r11-7256-g72d78655a91bb2f89ac4432cfd6374380d6f9987
Author: Vladimir N. Makarov <vmakarov@redhat.com>
Date:   Tue Feb 16 10:27:56 2021 -0500

    [PR98096] inline-asm: Take inout operands into account for access to labels
by names.

    GCC splits inout operands into output and new matched input operands
    during gimplfication.  Addressing operands by name or number is not
    problem as the new input operands are added at the end of existing
    input operands.  However it became a problem for labels in asm goto
    with output reloads.  Addressing labels should take into account the
    new input operands.  The patch solves the problem.

    gcc/ChangeLog:

            PR inline-asm/98096
            * stmt.c (resolve_operand_name_1): Take inout operands into account
            for access to labels by names.
            * doc/extend.texi: Describe counting operands for accessing labels.

    gcc/testsuite/ChangeLog:

            PR inline-asm/98096
            * gcc.c-torture/compile/pr98096.c: New.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug inline-asm/98096] Inconsistent operand numbering for asm goto with in-out operands
  2020-12-02 13:43 [Bug inline-asm/98096] New: Inconsistent operand numbering for asm goto with in-out operands jwjagersma at gmail dot com
  2020-12-02 23:37 ` [Bug inline-asm/98096] " pinskia at gcc dot gnu.org
  2021-02-16 15:30 ` cvs-commit at gcc dot gnu.org
@ 2021-09-14  7:48 ` pinskia at gcc dot gnu.org
  2021-12-10  1:46 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-14  7:48 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |11.0

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug inline-asm/98096] Inconsistent operand numbering for asm goto with in-out operands
  2020-12-02 13:43 [Bug inline-asm/98096] New: Inconsistent operand numbering for asm goto with in-out operands jwjagersma at gmail dot com
                   ` (2 preceding siblings ...)
  2021-09-14  7:48 ` pinskia at gcc dot gnu.org
@ 2021-12-10  1:46 ` pinskia at gcc dot gnu.org
  2021-12-10 23:33 ` ndesaulniers at google dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-10  1:46 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ndesaulniers at google dot com

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 103640 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug inline-asm/98096] Inconsistent operand numbering for asm goto with in-out operands
  2020-12-02 13:43 [Bug inline-asm/98096] New: Inconsistent operand numbering for asm goto with in-out operands jwjagersma at gmail dot com
                   ` (3 preceding siblings ...)
  2021-12-10  1:46 ` pinskia at gcc dot gnu.org
@ 2021-12-10 23:33 ` ndesaulniers at google dot com
  2021-12-11  0:13 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ndesaulniers at google dot com @ 2021-12-10 23:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Nick Desaulniers <ndesaulniers at google dot com> ---
While the changes to gcc/stmt.c and the second asm goto statement in
gcc/testsuite/gcc.c-torture/compile/pr98096.c in
https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=72d78655a91bb2f89ac4432cfd6374380d6f9987
LGTM (they fix an actual bug with symbolic references), the changes to
gcc/doc/extend.texi and the first asm goto statement in
gcc/testsuite/gcc.c-torture/compile/pr98096.c seemed to have conflated the
label bug with documenting curious behavior.

Was it ever consider that the behavior should be changed, rather than
documented?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug inline-asm/98096] Inconsistent operand numbering for asm goto with in-out operands
  2020-12-02 13:43 [Bug inline-asm/98096] New: Inconsistent operand numbering for asm goto with in-out operands jwjagersma at gmail dot com
                   ` (4 preceding siblings ...)
  2021-12-10 23:33 ` ndesaulniers at google dot com
@ 2021-12-11  0:13 ` pinskia at gcc dot gnu.org
  2022-01-05 17:50 ` foom at fuhm dot net
  2022-01-05 17:54 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-11  0:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Nick Desaulniers from comment #5)
> Was it ever consider that the behavior should be changed, rather than
> documented?

Seems like changing an already documented and released feature seems wrong. Gcc
11 was released back in April. Clang never documented this feature as far as I
can tell. Plus it would be very inconsistent with the way the inout feature was
handled without asm goto. That is all input constraints are grouped together,
having the asm goto label in between the inputs seems wrong.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug inline-asm/98096] Inconsistent operand numbering for asm goto with in-out operands
  2020-12-02 13:43 [Bug inline-asm/98096] New: Inconsistent operand numbering for asm goto with in-out operands jwjagersma at gmail dot com
                   ` (5 preceding siblings ...)
  2021-12-11  0:13 ` pinskia at gcc dot gnu.org
@ 2022-01-05 17:50 ` foom at fuhm dot net
  2022-01-05 17:54 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: foom at fuhm dot net @ 2022-01-05 17:50 UTC (permalink / raw)
  To: gcc-bugs

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

James Y Knight <foom at fuhm dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |foom at fuhm dot net

--- Comment #7 from James Y Knight <foom at fuhm dot net> ---
Previously, you never needed to care about the numbering of the extra hidden
input constraints generated for an in-out constraints, because they were
_last_. Their existence previously only mattered in that you needed to count
them as part of the "max 30" constraint limit.

That's why it is sensible to _keep_ these internal constraints last -- after
ALL user-specified constraints, including asm-goto labels. Putting in the
middle, and forcing users to count them just adds extra unnecessary complexity
to the user-facing API.

It appears to me that the GCC decision here was accidental, and that when
pointed out, the bug was simply documented rather than fixed. That's
unfortunate.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug inline-asm/98096] Inconsistent operand numbering for asm goto with in-out operands
  2020-12-02 13:43 [Bug inline-asm/98096] New: Inconsistent operand numbering for asm goto with in-out operands jwjagersma at gmail dot com
                   ` (6 preceding siblings ...)
  2022-01-05 17:50 ` foom at fuhm dot net
@ 2022-01-05 17:54 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-01-05 17:54 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
That isn't easibly possible, the labels are really significantly different from
the implementation POV, so having them intermixed with inputs is hard.
If you don't want to count on those extra inputs, name the labels...

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-01-05 17:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-02 13:43 [Bug inline-asm/98096] New: Inconsistent operand numbering for asm goto with in-out operands jwjagersma at gmail dot com
2020-12-02 23:37 ` [Bug inline-asm/98096] " pinskia at gcc dot gnu.org
2021-02-16 15:30 ` cvs-commit at gcc dot gnu.org
2021-09-14  7:48 ` pinskia at gcc dot gnu.org
2021-12-10  1:46 ` pinskia at gcc dot gnu.org
2021-12-10 23:33 ` ndesaulniers at google dot com
2021-12-11  0:13 ` pinskia at gcc dot gnu.org
2022-01-05 17:50 ` foom at fuhm dot net
2022-01-05 17:54 ` jakub at gcc dot gnu.org

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).