public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: liuhongt via Gcc-patches <gcc-patches@gcc.gnu.org>
Cc: liuhongt <hongtao.liu@intel.com>
Subject: Re: [PATCH] [RTL/fwprop] Allow propagations from inner loop to outer loop.
Date: Fri, 07 Jan 2022 12:00:13 +0000	[thread overview]
Message-ID: <mpto84nycvm.fsf@arm.com> (raw)
In-Reply-To: <20220107051629.27710-1-hongtao.liu@intel.com> (liuhongt via Gcc-patches's message of "Fri, 7 Jan 2022 13:16:29 +0800")

liuhongt via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
>>Huh, loop_father should never be NULL. Maybe when fwprop is run after RTL loop opts you instead want to add a check for current_loops or alternelatively initialize loops in fwprop.
>
> Oh, I didn't know that, i once saw there's ICE and thought it's related to
> NULL loop. But I can't reproduce the ICE either in GCC testsuite or buiding
> spec2017. Anyway, here's update patch.
>
> gcc/ChangeLog:
>
> 	PR rtl/103750
> 	* fwprop.c (forward_propagate_into): Allow propagations from
> 	inner loop to outer loop.
>
> gcc/testsuite/ChangeLog:
>
> 	* g++.target/i386/pr103750-fwprop-1.C: New test.
> ---
>  build.log                                     |  0
>  gcc/fwprop.c                                  |  7 +++--
>  .../g++.target/i386/pr103750-fwprop-1.C       | 26 +++++++++++++++++++
>  3 files changed, 31 insertions(+), 2 deletions(-)
>  create mode 100644 build.log
>  create mode 100644 gcc/testsuite/g++.target/i386/pr103750-fwprop-1.C
>
> diff --git a/build.log b/build.log
> new file mode 100644
> index 00000000000..e69de29bb2d
> diff --git a/gcc/fwprop.c b/gcc/fwprop.c
> index 2eab4fd4614..4f5d6a8d4fc 100644
> --- a/gcc/fwprop.c
> +++ b/gcc/fwprop.c
> @@ -866,10 +866,13 @@ forward_propagate_into (use_info *use, bool reg_prop_only = false)
>    rtx src = SET_SRC (def_set);
>  
>    /* Allow propagations into a loop only for reg-to-reg copies, since
> -     replacing one register by another shouldn't increase the cost.  */
> +     replacing one register by another shouldn't increase the cost.
> +     Propagations from inner loop to outer loop should be also ok.  */

“should also be ok”

OK with that change, thanks.

Richard

>    struct loop *def_loop = def_insn->bb ()->cfg_bb ()->loop_father;
>    struct loop *use_loop = use->bb ()->cfg_bb ()->loop_father;
> -  if ((reg_prop_only || def_loop != use_loop)
> +  if ((reg_prop_only
> +       || (def_loop != use_loop
> +	   && !flow_loop_nested_p (use_loop, def_loop)))
>        && (!reg_single_def_p (dest) || !reg_single_def_p (src)))
>      return false;
>  
> diff --git a/gcc/testsuite/g++.target/i386/pr103750-fwprop-1.C b/gcc/testsuite/g++.target/i386/pr103750-fwprop-1.C
> new file mode 100644
> index 00000000000..26987d307aa
> --- /dev/null
> +++ b/gcc/testsuite/g++.target/i386/pr103750-fwprop-1.C
> @@ -0,0 +1,26 @@
> +/* PR target/103750.  */
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -std=c++1y -march=cannonlake -fdump-rtl-fwprop1" } */
> +/* { dg-final { scan-rtl-dump-not "subreg:HI\[ \\\(\]*reg:SI\[^\n]*\n\[^\n]*UNSPEC_TZCNT" "fwprop1" } } */
> +
> +#include<immintrin.h>
> +const char16_t *qustrchr(char16_t *n, char16_t *e, char16_t c) noexcept
> +{
> +  __m256i mch256 = _mm256_set1_epi16(c);
> +  for ( ; n < e; n += 32) {
> +    __m256i data1 = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(n));
> +    __m256i data2 = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(n) + 1);
> +    __mmask16 mask1 = _mm256_cmpeq_epu16_mask(data1, mch256);
> +    __mmask16 mask2 = _mm256_cmpeq_epu16_mask(data2, mch256);
> +    if (_kortestz_mask16_u8(mask1, mask2))
> +      continue;
> +
> +    unsigned idx = _tzcnt_u32(mask1);
> +    if (mask1 == 0) {
> +      idx = __tzcnt_u16(mask2);
> +      n += 16;
> +    }
> +    return n + idx;
> +  }
> +  return e;
> +}

      reply	other threads:[~2022-01-07 12:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-05  5:38 liuhongt
2022-01-05  8:07 ` Richard Biener
2022-01-06  6:51   ` liuhongt
2022-01-06 10:55     ` Richard Biener
2022-01-07  5:16       ` liuhongt
2022-01-07 12:00         ` Richard Sandiford [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=mpto84nycvm.fsf@arm.com \
    --to=richard.sandiford@arm.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).