public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: liuhongt <hongtao.liu@intel.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] [x86] Add some preference for floating point rtl ifcvt when sse4.1 is not available
Date: Mon, 3 Jun 2024 09:14:32 +0200	[thread overview]
Message-ID: <CAFULd4aJArxC9ddn7Ks2_Hd0jZkVCaTX3mZOmM3XZh+d=2ubuA@mail.gmail.com> (raw)
In-Reply-To: <20240603030912.71411-1-hongtao.liu@intel.com>

On Mon, Jun 3, 2024 at 5:11 AM liuhongt <hongtao.liu@intel.com> wrote:
>
> W/o TARGET_SSE4_1, it takes 3 instructions (pand, pandn and por) for
> movdfcc/movsfcc, and could possibly fail cost comparison. Increase
> branch cost could hurt performance for other modes, so specially add
> some preference for floating point ifcvt.
>
> Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}.
> Ok for trunk?
>
> gcc/ChangeLog:
>
>         * config/i386/i386.cc (ix86_noce_conversion_profitable_p): Add
>         some preference for floating point ifcvt when SSE4.1 is not
>         available.
>
> gcc/testsuite/ChangeLog:
>
>         * gcc.target/i386/pr115299.c: New test.
>         * gcc.target/i386/pr86722.c: Adjust testcase.

LGTM.

Thanks,
Uros.

> ---
>  gcc/config/i386/i386.cc                  | 17 +++++++++++++++++
>  gcc/testsuite/gcc.target/i386/pr115299.c | 10 ++++++++++
>  gcc/testsuite/gcc.target/i386/pr86722.c  |  2 +-
>  3 files changed, 28 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/gcc.target/i386/pr115299.c
>
> diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
> index 1a0206ab573..271da127a89 100644
> --- a/gcc/config/i386/i386.cc
> +++ b/gcc/config/i386/i386.cc
> @@ -24879,6 +24879,23 @@ ix86_noce_conversion_profitable_p (rtx_insn *seq, struct noce_if_info *if_info)
>             return false;
>         }
>      }
> +
> +  /* W/o TARGET_SSE4_1, it takes 3 instructions (pand, pandn and por)
> +     for movdfcc/movsfcc, and could possibly fail cost comparison.
> +     Increase branch cost will hurt performance for other modes, so
> +     specially add some preference for floating point ifcvt.  */
> +  if (!TARGET_SSE4_1 && if_info->x
> +      && GET_MODE_CLASS (GET_MODE (if_info->x)) == MODE_FLOAT
> +      && if_info->speed_p)
> +    {
> +      unsigned cost = seq_cost (seq, true);
> +
> +      if (cost <= if_info->original_cost)
> +       return true;
> +
> +      return cost <= (if_info->max_seq_cost + COSTS_N_INSNS (2));
> +    }
> +
>    return default_noce_conversion_profitable_p (seq, if_info);
>  }
>
> diff --git a/gcc/testsuite/gcc.target/i386/pr115299.c b/gcc/testsuite/gcc.target/i386/pr115299.c
> new file mode 100644
> index 00000000000..53c5899136a
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr115299.c
> @@ -0,0 +1,10 @@
> +/* { dg-do compile { target { ! ia32 } } } */
> +/* { dg-options "-O2 -mno-sse4.1 -msse2" } */
> +
> +void f(double*d,double*e){
> +  for(;d<e;++d)
> +    *d=(*d<.5)?.7:0;
> +}
> +
> +/* { dg-final { scan-assembler {(?n)(?:cmpnltsd|cmpltsd)} } } */
> +/* { dg-final { scan-assembler {(?n)(?:andnpd|andpd)} } } */
> diff --git a/gcc/testsuite/gcc.target/i386/pr86722.c b/gcc/testsuite/gcc.target/i386/pr86722.c
> index 4de2ca1a6c0..e266a1e56c2 100644
> --- a/gcc/testsuite/gcc.target/i386/pr86722.c
> +++ b/gcc/testsuite/gcc.target/i386/pr86722.c
> @@ -6,5 +6,5 @@ void f(double*d,double*e){
>      *d=(*d<.5)?.7:0;
>  }
>
> -/* { dg-final { scan-assembler-not "andnpd" } } */
> +/* { dg-final { scan-assembler-times {(?n)(?:andnpd|andpd)} 1 } } */
>  /* { dg-final { scan-assembler-not "orpd" } } */
> --
> 2.31.1
>

      reply	other threads:[~2024-06-03  7:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-03  3:09 liuhongt
2024-06-03  7:14 ` Uros Bizjak [this message]

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='CAFULd4aJArxC9ddn7Ks2_Hd0jZkVCaTX3mZOmM3XZh+d=2ubuA@mail.gmail.com' \
    --to=ubizjak@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hongtao.liu@intel.com \
    /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).