public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/108941] Error: operand type mismatch for `shr' with binutils master
Date: Tue, 28 Feb 2023 07:47:36 +0000	[thread overview]
Message-ID: <bug-108941-4-KNGhOhplMK@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108941-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #15 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to jbeulich from comment #14)
> (In reply to Jakub Jelinek from comment #5)
> > GCC doesn't even have that information at all, at the RTL level it doesn't
> > know
> > if it was signed or unsigned.
> > All it has is the constraint and operand for it, like (reg:QI 126) or
> > (const_int -1).
> 
> Lack of information at a certain layer doesn't mean this isn't a bug. It
> merely makes whatever possible bug one that's hard to fix.

Well, we are talking about behavior of an extension that behaved since its
introduction that way and lots of code in the wild can rely on that behavior.
So, why would you all of sudden consider it a bug?

> Furthermore you did refer to gcc internal doc as to justifying the behavior.
> But can you also point me at non-internal doc making explicit that e.g.
> 
> static inline unsigned aux(unsigned i, unsigned char j) {
> #if 1
> 	asm("add %1,%0" : "+rm" (i) : "i" (j));

This is just misunderstanding on how inline asm works.  GCC (intentionally)
treats
inline asm as a black box, text in which it does replacements according to the
rules,
it is a very low level interface and needs the author know what they are doing.
Above you're mixing a 32-bit argument with 8-bit argument in an instruction
which
expects probably 2 32-bit arguments or at least both arguments with the same
width.
Just try to pass 2 variables to it and use "ri" and you'll see assembler
errors,
add %dl, %eax and the like.  There are various modifiers (often target
specific) which
allows one to say a particular operand should be printed as if in this mode,
when you don't use them, it means the operand mode is to be used.
So, for add above one should really use "i" ((int) j) if you want it 32-bit.
Similarly how ffmpeg should be using "rI" instead of "ri" that it uses...
     'I'
          Integer constant in the range 0 ... 31, for 32-bit shifts.
even documents it that way.

  parent reply	other threads:[~2023-02-28  7:47 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-27  9:39 [Bug c/108941] New: " marxin at gcc dot gnu.org
2023-02-27  9:51 ` [Bug c/108941] " jakub at gcc dot gnu.org
2023-02-27 10:00 ` marxin at gcc dot gnu.org
2023-02-27 10:07 ` jakub at gcc dot gnu.org
2023-02-27 10:17 ` jbeulich at suse dot com
2023-02-27 10:33 ` jakub at gcc dot gnu.org
2023-02-27 10:57 ` jbeulich at suse dot com
2023-02-27 11:00 ` jbeulich at suse dot com
2023-02-27 11:02 ` jakub at gcc dot gnu.org
2023-02-27 11:11 ` jbeulich at suse dot com
2023-02-27 11:14 ` jakub at gcc dot gnu.org
2023-02-27 11:17 ` jakub at gcc dot gnu.org
2023-02-27 11:17 ` marxin at gcc dot gnu.org
2023-02-27 11:23 ` jakub at gcc dot gnu.org
2023-02-28  7:33 ` jbeulich at suse dot com
2023-02-28  7:47 ` jakub at gcc dot gnu.org [this message]
2023-02-28  7:59 ` jbeulich at suse dot com
2023-02-28  8:10 ` jakub 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-108941-4-KNGhOhplMK@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).