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/114894] `a == 0 ? 0 : a * b` -> `a * b` likewise for `a & b`
Date: Tue, 07 May 2024 21:42:55 +0000	[thread overview]
Message-ID: <bug-114894-4-tuqLokNDyE@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114894-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from GCC 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:e472527c7b45d23e8dfd0fb767a6e663b4bc136e

commit r15-307-ge472527c7b45d23e8dfd0fb767a6e663b4bc136e
Author: Andrew Pinski <quic_apinski@quicinc.com>
Date:   Tue Apr 30 14:45:26 2024 -0700

    MATCH: Add some more value_replacement simplifications (a != 0 ? expr : 0)
to match

    This adds a few more of what is currently done in phiopt's
value_replacement
    to match. I noticed this when I was hooking up phiopt's value_replacement
    code to use match and disabling the old code. But this can be done
    independently from the hooking up phiopt's value_replacement as phiopt
    is already hooked up for simplified versions already.

    /* a != 0 ? a / b : 0  -> a / b iff b is nonzero. */
    /* a != 0 ? a * b : 0 -> a * b */
    /* a != 0 ? a & b : 0 -> a & b */

    We prefer the `cond ? a : 0` forms to allow optimization of `a * cond`
which
    uses that form.

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

            PR tree-optimization/114894

    gcc/ChangeLog:

            * match.pd (`a != 0 ? a / b : 0`): New pattern.
            (`a != 0 ? a * b : 0`): New pattern.
            (`a != 0 ? a & b : 0`): New pattern.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/phi-opt-value-5.c: New test.

    Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>

  parent reply	other threads:[~2024-05-07 21:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-30  6:18 [Bug tree-optimization/114894] New: " pinskia at gcc dot gnu.org
2024-04-30  6:18 ` [Bug tree-optimization/114894] " pinskia at gcc dot gnu.org
2024-04-30  6:23 ` pinskia at gcc dot gnu.org
2024-04-30 18:04 ` pinskia at gcc dot gnu.org
2024-04-30 18:18 ` pinskia at gcc dot gnu.org
2024-05-07 21:42 ` cvs-commit at gcc dot gnu.org [this message]
2024-05-07 21:43 ` 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-114894-4-tuqLokNDyE@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).