public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Andrew Pinski <apinski@marvell.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 4/7] MIN/MAX should be treated similar as comparisons for trapping
Date: Thu, 27 Apr 2023 12:49:51 +0200	[thread overview]
Message-ID: <CAFiYyc31b-AjXi5VASd=YB6zkaaM3pzbVLMUwC9Le08gCEEOog@mail.gmail.com> (raw)
In-Reply-To: <20230424213011.528181-5-apinski@marvell.com>

On Mon, Apr 24, 2023 at 11:31 PM Andrew Pinski via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> While looking into moving optimizations from minmax_replacement
> in phiopt to match.pd, I Noticed that min/max were considered
> trapping even if -ffinite-math-only was being used. This changes
> those expressions to be similar as comparisons so that they are
> not considered trapping if -ffinite-math-only is on.
>
> OK? Bootstrapped and tested with no regressions on x86_64-linux-gnu.

OK.

> gcc/ChangeLog:
>
>         * rtlanal.cc (may_trap_p_1): Treat SMIN/SMAX similar as
>         COMPARISON.
>         * tree-eh.cc (operation_could_trap_helper_p): Treate
>         MIN_EXPR/MAX_EXPR similar as other comparisons.
> ---
>  gcc/rtlanal.cc | 3 +++
>  gcc/tree-eh.cc | 3 +++
>  2 files changed, 6 insertions(+)
>
> diff --git a/gcc/rtlanal.cc b/gcc/rtlanal.cc
> index c96a88cebf1..b7948ecfad1 100644
> --- a/gcc/rtlanal.cc
> +++ b/gcc/rtlanal.cc
> @@ -3204,6 +3204,9 @@ may_trap_p_1 (const_rtx x, unsigned flags)
>      case LT:
>      case LTGT:
>      case COMPARE:
> +    /* Treat min/max similar as comparisons.  */
> +    case SMIN:
> +    case SMAX:
>        /* Some floating point comparisons may trap.  */
>        if (!flag_trapping_math)
>         break;
> diff --git a/gcc/tree-eh.cc b/gcc/tree-eh.cc
> index 41cf57d2b30..dbaa27d95c5 100644
> --- a/gcc/tree-eh.cc
> +++ b/gcc/tree-eh.cc
> @@ -2490,6 +2490,9 @@ operation_could_trap_helper_p (enum tree_code op,
>      case GT_EXPR:
>      case GE_EXPR:
>      case LTGT_EXPR:
> +    /* MIN/MAX similar as LT/LE/GT/GE. */
> +    case MIN_EXPR:
> +    case MAX_EXPR:
>        /* Some floating point comparisons may trap.  */
>        return honor_nans;
>
> --
> 2.39.1
>

  reply	other threads:[~2023-04-27 10:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24 21:30 [PATCH 0/7] Some more phiopt cleanups and double minmax to match Andrew Pinski
2023-04-24 21:30 ` [PATCH 1/7] PHIOPT: Split out store elimination from phiopt Andrew Pinski
2023-04-27 10:50   ` Richard Biener
2023-04-24 21:30 ` [PATCH 2/7] PHIOPT: Rename tree_ssa_phiopt_worker to pass_phiopt::execute Andrew Pinski
2023-04-27 10:58   ` Richard Biener
2023-04-24 21:30 ` [PATCH 3/7] PHIOPT: Move store_elim_worker into pass_cselim::execute Andrew Pinski
2023-04-27 10:50   ` Richard Biener
2023-04-24 21:30 ` [PATCH 4/7] MIN/MAX should be treated similar as comparisons for trapping Andrew Pinski
2023-04-27 10:49   ` Richard Biener [this message]
2023-04-24 21:30 ` [PATCH 5/7] PHIOPT: Allow MIN/MAX to have up to 2 MIN/MAX expressions for early phiopt Andrew Pinski
2023-04-27 10:51   ` Richard Biener
2023-04-24 21:30 ` [PATCH 6/7] MATCH: Factor out code that for min max detection with constants Andrew Pinski
2023-04-25 10:45   ` Mikael Morin
2023-04-24 21:30 ` [PATCH 7/7] MATCH: Add patterns from phiopt's minmax_replacement Andrew Pinski
2023-04-27 10: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='CAFiYyc31b-AjXi5VASd=YB6zkaaM3pzbVLMUwC9Le08gCEEOog@mail.gmail.com' \
    --to=richard.guenther@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).