public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Krister Walfridsson <krister.walfridsson@gmail.com>
To: gcc@gcc.gnu.org
Subject: types in GIMPLE IR
Date: Wed, 28 Jun 2023 09:15:39 +0000 (UTC)	[thread overview]
Message-ID: <Pine.NEB.4.64.2306280912400.11623@gateway.kwa> (raw)

I have some random questions concerning types in the GIMPLE IR that I 
would appreciate some clarification on.


Type safety
-----------
Some transformations treat 1-bit types as a synonym of _Bool and mix the 
types in expressions, such as:

   <unnamed-unsigned:1> _2;
   _Bool _3;
   _Bool _4;
   ...
   _4 = _2 ^ _3;

and similarly mixing _Bool and enum

   enum E:bool { E0, E1 };

in one operation.

I had expected this to be invalid... What are the type safety rules in the 
GIMPLE IR?


Somewhat related, gcc.c-torture/compile/pr96796.c performs a 
VIEW_CONVERT_EXPR from

   struct S1 {
     long f3;
     char f4;
   } g_3_4;

to an int

   p_51_9 = VIEW_CONVERT_EXPR<int>(g_3_4);

That must be wrong?


Semantics of <signed-boolean:32>
--------------------------------
"Wide" Booleans, such as <signed-boolean:32>, seems to allow more values 
than 0 and 1. For example, I've seen some IR operations like:

   _66 = _16 ? _Literal (<signed-boolean:32>) -1 : 0;

But I guess there must be some semantic difference between 
<signed-boolean:32> and a 32-bit int, otherwise the wide Boolean type 
would not be needed... So what are the difference?

    /Krister

             reply	other threads:[~2023-06-28  9:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-28  9:15 Krister Walfridsson [this message]
2023-06-28 15:46 ` Michael Matz
2023-06-29  6:21   ` Richard Biener
2023-06-29 12:06     ` Krister Walfridsson
2023-06-29 12:24       ` Michael Matz
2023-06-29 13:19       ` Richard Biener
2023-06-29 19:08         ` Krister Walfridsson
2023-06-29 19:32           ` Andrew Pinski

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=Pine.NEB.4.64.2306280912400.11623@gateway.kwa \
    --to=krister.walfridsson@gmail.com \
    --cc=gcc@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).