public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Richard Biener <rguenther@suse.de>,
	Tamar Christina <Tamar.Christina@arm.com>,
	 "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	nd <nd@arm.com>
Subject: Re: [PATCH] middle-end: fix de-optimizations with bitclear patterns on signed values
Date: Tue, 26 Oct 2021 20:35:40 +0100	[thread overview]
Message-ID: <CACb0b4=cRxjB3x_mT6Qd31Rouejm2fZnQZLGNvL7xbCDcUOmqA@mail.gmail.com> (raw)
In-Reply-To: <20211026133625.GZ304296@tucnak>

On Tue, 26 Oct 2021 at 14:36, Jakub Jelinek <jakub@redhat.com> wrote:

> On Tue, Oct 26, 2021 at 03:21:55PM +0200, Richard Biener wrote:
> > On Tue, 26 Oct 2021, Jakub Jelinek wrote:
> >
> > > On Tue, Oct 26, 2021 at 03:13:29PM +0200, Richard Biener wrote:
> > > > try
> > > >   auto c = ...;
> > > >   signed char c2 = c;
> > > >   return c2 >= ...
> > > > then
> > >
> > > That won't work, at least when using <compare>, which is what we with
> the
> > > optimization want to deal with primarily.
> > > Because std::partial_ordering etc. aren't implicitly nor explicitly
> > > convertible to int or signed char etc.
> > > Sure, one could in the testcase define its own std::strong_ordering
> etc.
> > > and define a conversion operator for it...
> >
> > So how do we end up with the signed char case in the first place?
> > Is the frontend using a type that's target dependent?
>
> <compare> uses explicitly signed char:
> namespace std
> {
>   // [cmp.categories], comparison category types
>   namespace __cmp_cat
>   {
>     using type = signed char;
>     enum class _Ord : type { equivalent = 0, less = -1, greater = 1 };
>     enum class _Ncmp : type { _Unordered = 2 };
> ...
> and __cmp_cat::type is what is used as type of _M_value of std::*_ordering
> -fsigned-char vs. -funsigned-char make no difference on the testcases on
> x86, but as mentioned in
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94589#c24
> some target decisions like load_extend_op uses in fold-const.c can affect
> it.  See https://gcc.gnu.org/pipermail/gcc-patches/2021-May/570714.html
>
>

We can change __cmp_cat::type if that would result in better code. I picked
signed char because we only need two bits, and preferably have a signed
type as it simplifies some things. Would int make more sense? Or int:2 ?

  parent reply	other threads:[~2021-10-26 19:35 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15 11:08 Tamar Christina
2021-10-15 11:30 ` Richard Biener
2021-10-25 14:26   ` Tamar Christina
2021-10-26  8:26     ` Richard Biener
2021-10-26  8:35       ` Tamar Christina
2021-10-26  8:45         ` Richard Biener
2021-10-26 12:10           ` Tamar Christina
2021-10-26 13:13             ` Richard Biener
2021-10-26 13:20               ` Jakub Jelinek
2021-10-26 13:21                 ` Richard Biener
2021-10-26 13:36                   ` Jakub Jelinek
2021-10-26 13:38                     ` Richard Biener
2021-10-26 19:35                     ` Jonathan Wakely [this message]
2021-10-26 19:39                       ` Jakub Jelinek
2021-10-26 19:50                         ` Jonathan Wakely
2021-11-03 10:56                           ` Tamar Christina
2021-11-03 14:20                             ` Jakub Jelinek
2021-11-04 12:19                               ` Tamar Christina
2021-11-04 15:10                                 ` Jakub Jelinek
2021-11-12  7:30                                   ` Tamar Christina
2021-11-19  8:52                                     ` Tamar Christina
2021-11-19 11:19                                     ` Jakub Jelinek

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='CACb0b4=cRxjB3x_mT6Qd31Rouejm2fZnQZLGNvL7xbCDcUOmqA@mail.gmail.com' \
    --to=jwakely@redhat.com \
    --cc=Tamar.Christina@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=nd@arm.com \
    --cc=rguenther@suse.de \
    /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).