public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Richard Biener <rguenther@suse.de>, Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] tree-ssa-math-opts: popcount (X) == 1 to (X ^ (X - 1)) > (X - 1) optimization [PR90693]
Date: Mon, 20 Nov 2023 06:03:37 -0700	[thread overview]
Message-ID: <8a6a139c-e432-4c15-85c6-3362b277ca2a@gmail.com> (raw)
In-Reply-To: <nycvar.YFH.7.77.849.2311200838100.8772@jbgna.fhfr.qr>



On 11/20/23 01:39, Richard Biener wrote:
> On Mon, 20 Nov 2023, Jakub Jelinek wrote:
> 
>> On Mon, Nov 20, 2023 at 07:54:54AM +0000, Richard Biener wrote:
>>> On Fri, 17 Nov 2023, Jakub Jelinek wrote:
>>>> Per the earlier discussions on this PR, the following patch folds
>>>> popcount (x) == 1 (and != 1) into (x ^ (x - 1)) > x - 1 (or <=)
>>>> if the corresponding popcount optab isn't implemented (I think any
>>>> double-word popcount or call will be necessarily slower than the
>>>> above cheap 3 op check and even for -Os larger or same size).
>>>>
>>>> I've noticed e.g. C++ aligned new starts with std::has_single_bit
>>>> which does popcount (x) == 1.
>>>>
>>>> As a follow-up, I'm considering changing in this routine the popcount
>>>> call to IFN_POPCOUNT with 2 arguments and during expansion test costs.
>>>>
>>>> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>>>
>>> Classically this would have been an RTL expansion alternative, given
>>> we want to do less of those the next place would have been the ISEL
>>> pass.  Any particular reason you chose widening-mul for this (guess
>>> that pass just has a bad name and it's the effective "optimize" ISEL pass
>>> we have).
>>
>> I think the ssa-math-opts pass does far more of this staff than the isel
>> pass which only deals with vector stuff right now and you've even mentioned
>> that pass for that in the PR90693 thread.
>> That said, I can move it into the isel pass as well if you prefer that.
> 
> I think it's fine as you posted (and Jeff approved), I'm just wondering
> if we should rename that pass somehow ;)  Note ISEL is more for
> required pre-expansion stuff and widen-mul is for expansion related but
> optimization parts.
Yea, a rename seems appropriate given how much stuff in there is no 
longer math-ops related :-)
jeff

      parent reply	other threads:[~2023-11-20 13:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-17 14:01 Jakub Jelinek
2023-11-18 10:27 ` [PATCH] tree-ssa-math-opts: popcount (X) == 1 to (X ^ (X - 1)) > (X - 1) optimization for direct optab [PR90693] Jakub Jelinek
2023-11-19  4:03   ` Jeff Law
2023-11-20  8:01   ` Richard Biener
2023-11-20  9:05     ` Jakub Jelinek
2023-11-19  3:59 ` [PATCH] tree-ssa-math-opts: popcount (X) == 1 to (X ^ (X - 1)) > (X - 1) optimization [PR90693] Jeff Law
2023-11-20  7:54 ` Richard Biener
2023-11-20  8:37   ` Jakub Jelinek
2023-11-20  8:39     ` Richard Biener
2023-11-20  8:41       ` Jakub Jelinek
2023-11-20 13:03       ` Jeff Law [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=8a6a139c-e432-4c15-85c6-3362b277ca2a@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.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).