public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Hongtao Liu <crazylht@gmail.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: liuhongt <hongtao.liu@intel.com>,
	Michael Meissner <meissner@linux.ibm.com>,
	Andrew Waterman <andrew@sifive.com>,
	Segher Boessenkool <segher@kernel.crashing.org>,
	asolokha@gmx.com,  Andreas Schwab <schwab@linux-m68k.org>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 2/2] validate_subreg before call gen_lowpart to avoid ICE.
Date: Fri, 10 Sep 2021 22:25:45 +0800	[thread overview]
Message-ID: <CAMZc-byeXhdcYV0sbjCtGLY2r26egbOsW8LfZi5y_CkSOgqU1g@mail.gmail.com> (raw)
In-Reply-To: <CAMZc-bxCNLLT9mJ6mYEzJbP4DW58tC1V1-kiOmY8dx-JeRan7g@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4057 bytes --]

On Fri, Sep 10, 2021 at 9:44 PM Hongtao Liu <crazylht@gmail.com> wrote:
>
> On Fri, Sep 10, 2021 at 9:32 PM Richard Biener
> <richard.guenther@gmail.com> wrote:
> >
> > On September 10, 2021 3:27:09 PM GMT+02:00, Hongtao Liu <crazylht@gmail.com> wrote:
> > >On Fri, Sep 10, 2021 at 9:16 PM Richard Biener via Gcc-patches
> > ><gcc-patches@gcc.gnu.org> wrote:
> > >>
> > >> On Fri, Sep 10, 2021 at 2:58 PM liuhongt <hongtao.liu@intel.com> wrote:
> > >> >
> > >> > gcc/ChangeLog:
> > >> >
> > >> >         * expmed.c (extract_bit_field_using_extv): validate_subreg
> > >> >         before call gen_lowpart.
> > >> > ---
> > >> >  gcc/expmed.c | 6 +++++-
> > >> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > >> >
> > >> > diff --git a/gcc/expmed.c b/gcc/expmed.c
> > >> > index 3143f38e057..10d62d857a8 100644
> > >> > --- a/gcc/expmed.c
> > >> > +++ b/gcc/expmed.c
> > >> > @@ -1571,12 +1571,16 @@ extract_bit_field_using_extv (const extraction_insn *extv, rtx op0,
> > >> >
> > >> >    if (GET_MODE (target) != ext_mode)
> > >> >      {
> > >> > +      machine_mode tmode = GET_MODE (target);
> > >> >        /* Don't use LHS paradoxical subreg if explicit truncation is needed
> > >> >          between the mode of the extraction (word_mode) and the target
> > >> >          mode.  Instead, create a temporary and use convert_move to set
> > >> >          the target.  */
> > >> >        if (REG_P (target)
> > >> > -         && TRULY_NOOP_TRUNCATION_MODES_P (GET_MODE (target), ext_mode))
> > >>
> > >> ^^^
> > >>
> > >> I wonder if herein lies the problem in that the HFmode "truncation" from SImode
> > >> is considered noop?  Note the underlying target hook only looks at the mode
> > >> precision and thus receives 16 and 32, and thus maybe that
> > >> TRULY_NOOP_TRUNCATION_MODES_P query only makes sense for
> > >> integer modes?  Though the documentation of the hook only talks about
> > >> "conversion" of "values" ...
> > >>
> > >> So maybe a targetm.modes_tieable_p (GET_MODE (target), extmode) check
> > >> is missing?
> > >
> > >According to document, it should be true for
> > >targetm.modes_tieable_p(HFmode, SImode) since HFmode can be allocated
> > >to gpr.
> > >
> > >----------------
> > >This hook returns true if a value of mode mode1 is accessible in mode
> > >mode2 without
> > >copying
> > >-------------------
> > >
> > >and also here gen_lowpart (SImode, HFmode, target) is called and hit
> > >gcc_assert, not (subreg:HF (reg:SI) 0)
> >
> > I see. Of course that leads to a suggestion to allow the subreg based on modes_tieable_p, but then others will know why that's the wrong thing to do?
> I'm testing this
>
> 1 file changed, 2 insertions(+), 1 deletion(-)
> gcc/expmed.c | 3 ++-
>
> modified   gcc/expmed.c
> @@ -1576,7 +1576,8 @@ extract_bit_field_using_extv (const
> extraction_insn *extv, rtx op0,
>   mode.  Instead, create a temporary and use convert_move to set
>   the target.  */
>        if (REG_P (target)
>         -   && TRULY_NOOP_TRUNCATION_MODES_P (GET_MODE (target), ext_mode))
>         +   && TRULY_NOOP_TRUNCATION_MODES_P (GET_MODE (target), ext_mode)
>         +   && targetm.modes_tieable_p (GET_MODE (target), ext_mode))
>   {
>     target = gen_lowpart (ext_mode, target);
>     if (partial_subreg_p (GET_MODE (spec_target), ext_mode))
>
Updated patch.

  Bootstrapped and regtested on x86_64-linux-gnu{-m32,},  do I need to
run this patch on other targets machine, or the patch is supposed to
have minimal impact on other targets?
  Then, ok for trunk?

> >
> > Richard.
> >
> > >>
> > >> > +         && TRULY_NOOP_TRUNCATION_MODES_P (tmode, ext_mode)
> > >> > +         && validate_subreg (ext_mode, tmode,
> > >> > +                             target,
> > >> > +                             subreg_lowpart_offset (ext_mode, tmode)))
> > >> >         {
> > >> >           target = gen_lowpart (ext_mode, target);
> > >> >           if (partial_subreg_p (GET_MODE (spec_target), ext_mode))
> > >> > --
> > >> > 2.27.0
> > >> >
> > >
> > >
> > >
> >
>
>
> --
> BR,
> Hongtao



-- 
BR,
Hongtao

[-- Attachment #2: v2-0001-Check-modes_tieable_p-before-call-gen_lowpart-to-.patch --]
[-- Type: application/octet-stream, Size: 1069 bytes --]

From e1a63d41ad733e46f28cff540cfacc4742488782 Mon Sep 17 00:00:00 2001
From: liuhongt <hongtao.liu@intel.com>
Date: Fri, 10 Sep 2021 22:15:36 +0800
Subject: [PATCH v2] Check modes_tieable_p before call gen_lowpart to avoid ICE
 in validate_subreg.

gcc/ChangeLog:

	* expmed.c (extract_bit_field_using_extv): Check
	modes_tieable_p before call gen_lowpart.
---
 gcc/expmed.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/expmed.c b/gcc/expmed.c
index 3143f38e057..fc1c973033c 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -1576,7 +1576,8 @@ extract_bit_field_using_extv (const extraction_insn *extv, rtx op0,
 	 mode.  Instead, create a temporary and use convert_move to set
 	 the target.  */
       if (REG_P (target)
-	  && TRULY_NOOP_TRUNCATION_MODES_P (GET_MODE (target), ext_mode))
+	  && TRULY_NOOP_TRUNCATION_MODES_P (GET_MODE (target), ext_mode)
+	  && targetm.modes_tieable_p (GET_MODE (target), ext_mode))
 	{
 	  target = gen_lowpart (ext_mode, target);
 	  if (partial_subreg_p (GET_MODE (spec_target), ext_mode))
-- 
2.27.0


  reply	other threads:[~2021-09-10 14:25 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-10 12:58 [PATCH 0/2] Revert r12-3277 since it caused regressions on many other targets liuhongt
2021-09-10 12:58 ` [PATCH 1/2] Revert "Get rid of all float-int special cases in validate_subreg." liuhongt
2021-09-10 13:05   ` Richard Biener
2021-09-10 12:58 ` [PATCH 2/2] validate_subreg before call gen_lowpart to avoid ICE liuhongt
2021-09-10 13:15   ` Richard Biener
2021-09-10 13:27     ` Hongtao Liu
2021-09-10 13:32       ` Richard Biener
2021-09-10 13:44         ` Hongtao Liu
2021-09-10 14:25           ` Hongtao Liu [this message]
2021-09-10 21:19             ` Segher Boessenkool
2021-09-11  0:29               ` Hongtao Liu
2021-09-11  1:04                 ` Hongtao Liu
2021-09-10 13:52         ` Hongtao Liu
2021-09-10 13:39       ` Hongtao Liu
2021-09-10 13:30     ` Segher Boessenkool
2021-09-10 13:58       ` Richard Biener
2021-09-10 16:24         ` Segher Boessenkool
2021-09-10 18:36           ` Richard Biener
2021-09-10 21:27             ` Segher Boessenkool
2021-09-11  8:25               ` Richard Biener
2021-09-11  9:51                 ` Hongtao Liu
2021-09-11 11:09                   ` Hongtao Liu
2021-09-13  6:10   ` Richard Biener
2021-09-13  6:32     ` Hongtao Liu
2021-09-13  9:15       ` Richard Biener
2021-09-13 11:14         ` Hongtao Liu
2021-09-13 11:44           ` Tobias Burnus
2021-09-13 11:45           ` 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=CAMZc-byeXhdcYV0sbjCtGLY2r26egbOsW8LfZi5y_CkSOgqU1g@mail.gmail.com \
    --to=crazylht@gmail.com \
    --cc=andrew@sifive.com \
    --cc=asolokha@gmx.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hongtao.liu@intel.com \
    --cc=meissner@linux.ibm.com \
    --cc=richard.guenther@gmail.com \
    --cc=schwab@linux-m68k.org \
    --cc=segher@kernel.crashing.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).