public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Eric Botcazou <botcazou@adacore.com>
To: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: PING^5: [PATCH] rtl-optimization/110939 Really fix narrow comparison of memory and constant
Date: Mon, 25 Sep 2023 12:52:14 +0200	[thread overview]
Message-ID: <10342490.nUPlyArG6x@fomalhaut> (raw)
In-Reply-To: <ZQnHH+szc2+Drh+J@li-819a89cc-2401-11b2-a85c-cca1ce6aa768.ibm.com>

> This is why I got a bit uncertain and hoped to get some feedback whether
> my intuition is correct or not.  Meanwhile I also found a comment in
> the internals book at "14.7 Constant Expression Types" where we have:
> 
>    "Constants generated for modes with fewer bits than in HOST_WIDE_INT
>     must be sign extended to full width (e.g., with gen_int_mode).
>     [...]
>     Note however that values are neither inherently signed nor
>     inherently unsigned; where necessary, signedness is determined by
>     the rtl operation instead."
> 
> At least this and the assert statement document that the normal form of
> a CONST_INT is kind of special w.r.t. unsigned integers.  Is there
> anyone who can shed some light on _why_ such a normal form was chosen?

In RTL integral values have no sign, they just represent a given pattern of 
bits so, in order to have a 1-to-1 mapping, you need to choose a canonical 
form.  The signed form is probably more natural and, since CONST_INTs have no 
mode, the same objects are used for e.g. QImode and HImode, which means that 
you need to sign-extend the bit pattern.

-- 
Eric Botcazou



  reply	other threads:[~2023-09-25 10:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-10 13:04 Stefan Schulze Frielinghaus
2023-08-12  1:04 ` Xi Ruoyao
2023-08-14  6:39   ` Stefan Schulze Frielinghaus
2023-08-18 11:04 ` Stefan Schulze Frielinghaus
2023-08-24  3:31   ` PING^2: " Xi Ruoyao
2023-09-04  5:55     ` PING^3: " Stefan Schulze Frielinghaus
2023-09-10 16:56       ` PING^4: " Xi Ruoyao
2023-09-19  7:31         ` PING^5: " Xi Ruoyao
2023-09-19 16:06           ` Stefan Schulze Frielinghaus
2023-09-25 10:52             ` Eric Botcazou [this message]
2023-09-29 18:51             ` Jeff Law
2023-08-29 10:24 ` Xi Ruoyao
2023-09-29 19:01 ` Jeff Law
2023-10-01 14:26   ` Stefan Schulze Frielinghaus
2023-10-01 14:36     ` Jeff Law

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=10342490.nUPlyArG6x@fomalhaut \
    --to=botcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=stefansf@linux.ibm.com \
    /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).