public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Andrew Pinski <apinski@marvell.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Simplify "1 - bool_val" to "bool_val ^ 1"
Date: Sun, 12 Feb 2023 23:41:34 -0700	[thread overview]
Message-ID: <b638fe16-813b-152e-eb82-1fc0a7baf0bb@gmail.com> (raw)
In-Reply-To: <20230201012112.1300516-1-apinski@marvell.com>



On 1/31/23 18:21, Andrew Pinski via Gcc-patches wrote:
> For bool values, it is easier to deal with
> xor 1 rather than having 1 - a. This is because
> we are more likely to simplify the xor further in many
> cases.
> 
> This is a special case for (MASK - b) where MASK
> is a powerof2 - 1 and b <= MASK but only for bool
> ranges ([0,1]) as that is the main case where the
> difference comes into play.
> 
> Note this is enabled for gimple folding only
> as the ranges are only know while doing gimple
> folding and cfun is not always set when fold is called.
> 
> OK? Bootstrapped and tested on x86_64-linux-gnu with no
> regressions.
> 
> gcc/ChangeLog:
> 
> 	PR tree-optimization/108355
> 	PR tree-optimization/96921
> 	* match.pd: Add pattern for "1 - bool_val".
> 
> gcc/testsuite/ChangeLog:
> 
> 	PR tree-optimization/108355
> 	PR tree-optimization/96921
> 	* gcc.dg/tree-ssa/bool-minus-1.c: New test.
> 	* gcc.dg/tree-ssa/bool-minus-2.c: New test.
> 	* gcc.dg/tree-ssa/pr108354-1.c: New test.
OK.
jeff

  reply	other threads:[~2023-02-13  6:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-01  1:21 Andrew Pinski
2023-02-13  6:41 ` Jeff Law [this message]
2023-02-01  1:29 Andrew Pinski
2023-02-01  7:58 ` Richard Biener

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=b638fe16-813b-152e-eb82-1fc0a7baf0bb@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=apinski@marvell.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).