public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/101590] (len & - N) <= len is not optimized to 1
Date: Fri, 27 Oct 2023 07:50:23 +0000	[thread overview]
Message-ID: <bug-101590-4-5qCQ6exuDR@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101590-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101590

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:

https://gcc.gnu.org/g:a5e69e94591ae282857d59e868ff6cea7306c802

commit r14-4965-ga5e69e94591ae282857d59e868ff6cea7306c802
Author: Andrew Pinski <apinski@marvell.com>
Date:   Tue Sep 12 18:24:22 2023 -0700

    MATCH: Simplify `(X &| B) CMP X` if possible [PR 101590]

    I noticed we were missing these simplifications so let's add them.

    This adds the following simplifications:
    U & N <= U  -> true
    U & N >  U  -> false
    When U is known to be as non-negative.

    When N is also known to be non-negative, this is also true:
    U | N <  U  -> false
    U | N >= U  -> true

    When N is a negative integer, the result flips and we get:
    U | N <  U  -> true
    U | N >= U  -> false

    We could extend this later on to be the case where we know N
    is nonconstant but is known to be negative.

    Bootstrapped and tested on x86_64-linux-gnu with no regressions.

            PR tree-optimization/101590
            PR tree-optimization/94884

    gcc/ChangeLog:

            * match.pd (`(X BIT_OP Y) CMP X`): New pattern.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/bitcmp-1.c: New test.
            * gcc.dg/tree-ssa/bitcmp-2.c: New test.
            * gcc.dg/tree-ssa/bitcmp-3.c: New test.
            * gcc.dg/tree-ssa/bitcmp-4.c: New test.
            * gcc.dg/tree-ssa/bitcmp-5.c: New test.
            * gcc.dg/tree-ssa/bitcmp-6.c: New test.

  parent reply	other threads:[~2023-10-27  7:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-23  3:40 [Bug tree-optimization/101590] New: " pinskia at gcc dot gnu.org
2021-07-27 10:34 ` [Bug tree-optimization/101590] " rguenth at gcc dot gnu.org
2021-07-27 19:48 ` pinskia at gcc dot gnu.org
2021-07-27 19:54 ` pinskia at gcc dot gnu.org
2023-08-23  0:32 ` pinskia at gcc dot gnu.org
2023-08-23  0:37 ` pinskia at gcc dot gnu.org
2023-10-24 16:03 ` pinskia at gcc dot gnu.org
2023-10-24 16:09 ` pinskia at gcc dot gnu.org
2023-10-24 21:57 ` pinskia at gcc dot gnu.org
2023-10-26  1:36 ` pinskia at gcc dot gnu.org
2023-10-27  7:50 ` cvs-commit at gcc dot gnu.org [this message]
2023-10-27  7:50 ` pinskia at gcc dot gnu.org

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=bug-101590-4-5qCQ6exuDR@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).