From: Richard Biener <richard.guenther@gmail.com>
To: Roger Sayle <roger@nextmovesoftware.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] PR middle-end/109840: Preserve popcount/parity type in match.pd.
Date: Wed, 24 May 2023 10:54:53 +0200 [thread overview]
Message-ID: <CAFiYyc1SLiHBEgPry0wQO+6XU6CTqYyPOC5PUNayciLm8gRVpQ@mail.gmail.com> (raw)
In-Reply-To: <075901d98da4$a1fc4dc0$e5f4e940$@nextmovesoftware.com>
On Tue, May 23, 2023 at 8:30 PM Roger Sayle <roger@nextmovesoftware.com> wrote:
>
>
> PR middle-end/109840 is a regression introduced by my recent patch to
> fold popcount(bswap(x)) as popcount(x). When the bswap and the popcount
> have the same precision, everything works fine, but this optimization also
> allowed a zero-extension between the two. The oversight is that we need
> to be strict with type conversions, both to avoid accidentally changing
> the argument type to popcount, and also to reflect the effects of
> argument/return-value promotion in the call to bswap, so this zero extension
> needs to be preserved/explicit in the optimized form.
>
> Interestingly, match.pd should (in theory) be able to narrow calls to
> popcount and parity, removing a zero-extension from its argument, but
> that is an independent optimization, that needs to check IFN_ support.
> Many thanks to Andrew Pinski for his help/fixes with these transformations.
>
> This patch has been tested on x86_64-pc-linux-gnu with make bootstrap
> and make -k check, both with and without --target_board=unix{-m32}
> with no new failures. Ok for mainline?
OK.
Thanks,
Richard.
>
> 2023-05-23 Roger Sayle <roger@nextmovesoftware.com>
>
> gcc/ChangeLog
> PR middle-end/109840
> * match.pd <popcount optimizations>: Preserve zero-extension when
> optimizing popcount((T)bswap(x)) and popcount((T)rotate(x,y)) as
> popcount((T)x), so the popcount's argument keeps the same type.
> <parity optimizations>: Likewise preserve extensions when
> simplifying parity((T)bswap(x)) and parity((T)rotate(x,y)) as
> parity((T)x), so that the parity's argument type is the same.
>
> gcc/testsuite/ChangeLog
> PR middle-end/109840
> * gcc.dg/fold-parity-8.c: New test.
> * gcc.dg/fold-popcount-11.c: Likewise.
>
>
> Thanks in advance, and apologies for any inconvenience.
> Roger
> --
>
prev parent reply other threads:[~2023-05-24 8:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-23 18:30 Roger Sayle
2023-05-24 8:54 ` Richard Biener [this message]
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=CAFiYyc1SLiHBEgPry0wQO+6XU6CTqYyPOC5PUNayciLm8gRVpQ@mail.gmail.com \
--to=richard.guenther@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=roger@nextmovesoftware.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).