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: Mon, 27 Feb 2023 11:02:28 +0000	[thread overview]
Message-ID: <bug-108941-4-tbdWmrq0d9@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 #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to jbeulich from comment #6)
> (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).
> > As I said earlier, constants are always sign-extended from their mode.
> > One could e.g. have during expansion (set (reg:QI 126) (const_int -1))
> > and later on asm_operands with "ic" and (reg:QI 126).  Same assignment for
> > int8_t x = -1 or int8_t x = 255 or uint8_t x = -1 or uint8_t x = 255, at
> > GIMPLE one can differentiate that based on types, at RTL one has just mode.
> 
> While for int8_t x = -1 or int8_t x = 255 I can see that the result is as
> described, for uint8_t x = -1 or uint8_t x = 255 (or, as in the example, a
> constant the was cast to an unsigned 8-bit type) why is it not (const int
> 255)?

Because RTL doesn't have the notion of signed/unsigned types, only modes (which
don't have a sign).  For many operations there is no difference in how they
behave with signed and unsigned values, say PLUS works the same.  And where it
matters, the signed vs. unsigned is encoded in the code of the operation (there
is say arithmetic right shift and logical right shift).  (const_int 255) is
invalid where 8-bit quantity is required.

  parent reply	other threads:[~2023-02-27 11:02 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 [this message]
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
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-tbdWmrq0d9@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).