public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: gcc-patches@gcc.gnu.org
Subject: Re: [COMMITTED] Optimize [0 = x & MASK] in range-ops.
Date: Mon, 26 Sep 2022 17:27:37 -0600	[thread overview]
Message-ID: <03c09537-4a4a-f77c-98b3-86808b1dd962@gmail.com> (raw)
In-Reply-To: <20220926172441.3219466-1-aldyh@redhat.com>


On 9/26/22 11:24, Aldy Hernandez via Gcc-patches wrote:
> For [0 = x & MASK], we can determine that x is ~MASK.  This is
> something we're picking up in DOM thanks to maybe_set_nonzero_bits,
> but is something we should handle natively.
>
> This is a good example of how much easier to maintain the range-ops
> entries are versus the ad-hoc pattern matching stuff we had to do
> before.  For the curious, compare the changes to range-op here,
> versus maybe_set_nonzero_bits.
>
> I'm leaving the call to maybe_set_nonzero_bits until I can properly
> audit it to make sure we're catching it all in range-ops.  It won't
> hurt, since both set_range_info() and set_nonzero_bits() are
> intersect operations, so we'll never lose information if we do both.
>
> Tested on x86-64 Linux.
>
> 	PR tree-optimization/107009
>
> gcc/ChangeLog:
>
> 	* range-op.cc (operator_bitwise_and::op1_range): Optimize 0 = x & MASK.
> 	(range_op_bitwise_and_tests): New test.

Umm,


0 = x & MASK;


Just means that X has no bits set in MASK.   So you can use it to set 
nonzero-bits to ~MASK like your patch does and you can use that to 
refine a result.  So it's really the comment that is misleading/wrong.


jeff


  reply	other threads:[~2022-09-26 23:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-26 17:24 Aldy Hernandez
2022-09-26 23:27 ` Jeff Law [this message]
2022-09-27  9:26 ` Mikael Morin

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=03c09537-4a4a-f77c-98b3-86808b1dd962@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gcc-patches@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).