public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/40209] ICE in iv_analyze_def caused by stale REG_UNUSED note
       [not found] <bug-40209-4@http.gcc.gnu.org/bugzilla/>
@ 2023-12-06 18:32 ` pinskia at gcc dot gnu.org
  2023-12-06 18:33 ` pinskia at gcc dot gnu.org
  2023-12-06 18:34 ` [Bug rtl-optimization/40209] stale REG_UNUSED note vs single_set pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-06 18:32 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sjames at gcc dot gnu.org

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 112572 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug rtl-optimization/40209] ICE in iv_analyze_def caused by stale REG_UNUSED note
       [not found] <bug-40209-4@http.gcc.gnu.org/bugzilla/>
  2023-12-06 18:32 ` [Bug rtl-optimization/40209] ICE in iv_analyze_def caused by stale REG_UNUSED note pinskia at gcc dot gnu.org
@ 2023-12-06 18:33 ` pinskia at gcc dot gnu.org
  2023-12-06 18:34 ` [Bug rtl-optimization/40209] stale REG_UNUSED note vs single_set pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-06 18:33 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |zsojka at seznam dot cz

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 112760 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug rtl-optimization/40209] stale REG_UNUSED note vs single_set
       [not found] <bug-40209-4@http.gcc.gnu.org/bugzilla/>
  2023-12-06 18:32 ` [Bug rtl-optimization/40209] ICE in iv_analyze_def caused by stale REG_UNUSED note pinskia at gcc dot gnu.org
  2023-12-06 18:33 ` pinskia at gcc dot gnu.org
@ 2023-12-06 18:34 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-06 18:34 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |internal-improvement,
                   |                            |wrong-code
   Last reconfirmed|                            |2023-12-06
            Summary|ICE in iv_analyze_def       |stale REG_UNUSED note vs
                   |caused by stale REG_UNUSED  |single_set
                   |note                        |
     Ever confirmed|0                           |1

--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug rtl-optimization/40209] ICE in iv_analyze_def caused by stale REG_UNUSED note
  2009-05-20 18:47 [Bug rtl-optimization/40209] New: ICE in iv opts caused by stale REG_UNUSED note nvachhar at google dot com
                   ` (4 preceding siblings ...)
  2009-07-24 17:05 ` steven at gcc dot gnu dot org
@ 2009-07-24 17:47 ` nvachhar at google dot com
  5 siblings, 0 replies; 9+ messages in thread
From: nvachhar at google dot com @ 2009-07-24 17:47 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3707 bytes --]



------- Comment #7 from nvachhar at google dot com  2009-07-24 17:47 -------
Subject: Re:  ICE in iv_analyze_def caused by 
        stale REG_UNUSED note

This looks reasonable to me.  Given the caveats you mention in the
comment, this would need to be tested for correctness (esp. w.r.t. the
newly added registers) and obviously would need to be tested for
performance regressions.

On Fri, Jul 24, 2009 at 5:04 PM, steven at gcc dot gnu dot
org<gcc-bugzilla@gcc.gnu.org> wrote:
>
>
> ------- Comment #6 from steven at gcc dot gnu dot org  2009-07-24 17:04 -------
> Then we should write a new function, something like this in df.h perhaps:
>
> /* Given an INSN, return a SET expression if the insn has only one
>   SET whose SET_DEST is used.  If SET_DEST is memory, then the SET is
>   assumed to be used somewhere, always.
>
>   This means that:
>   * If an insn has multiple SETs to only registers, but only one of those
>     SETs is used, return that one set.
>   * If an insn has multiple SETs to only registers, but none one of those
>     SETs is used, return NULL_RTX.
>   * If an insn has multiple SETs to registers and/or memory, but the SETs to
>     registers are dead, return the one memory SET, or NULL_RTX if there are
>     multiple sets to memory.
>
>   Only accept INSNs.  single_set() can take a pattern, but that is
>   "old skool" style that should be abolished.
>
>   May miss some single_set SETs that single_set() can find, because this
>   function just looks for the number of uses of a register to determine
>   whether a set is used (which may fail for hard registers and for unusual
>   situations with pseudos that somehow are set twice but never used) whereas
>   single_set() uses liveness information through REG_UNUSED notes.  Still,
>   I expect that, in practice, this function works just as well as
>   single_set().
>
>   One more caveat: The DF user must use incremental scanning, or the
>   DF_REG_USE_COUNT may be wrong.  The result of df_single_set would be
>   unconservative for new registers since the last scan (DF_REG_USE_COUNT
>   will still be 0, indicating the new reg is unused and its SET can be
>   ignored).  */
>
> rtx
> df_single_set (rtx insn)
> {
>  rtx pat;
>
>  gcc_assert (INSN_P (insn));
>
>  /* ??? Could even just fall back if the current DF mode is not incremental
>         scanning.  */
>  pat = PATTERN (insn);
>  if (GET_CODE (pat) == SET)
>    return pat;
>  else if (GET_CODE (pat) == PARALLEL)
>    {
>      int i;
>      rtx set = NULL_RTX;
>      for (i = 0; i < XVECLEN (pat, 0); i++)
>        {
>          rtx sub = XVECEXP (pat, 0, i);
>          switch (GET_CODE (sub))
>          {
>          case USE:
>          case CLOBBER:
>            break;
>
>          case SET:
>            if (! set)
>              {
>                rtx dest = SET_DEST (set);
>                if (GET_CODE (dest) == SUBREG)
>                  dest = SUBREG_REG (dest);
>                if (! REG_P (dest)
>                    || DF_REG_USE_COUNT (dest) > 0)
>                  set = sub;
>              }
>            else
>              return NULL_RTX;
>            break;
>
>          default:
>            return NULL_RTX;
>          }
>        }
>    }
>  else
>    return NULL_RTX;
> }
>
>
> --
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40209
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40209


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug rtl-optimization/40209] ICE in iv_analyze_def caused by stale REG_UNUSED note
  2009-05-20 18:47 [Bug rtl-optimization/40209] New: ICE in iv opts caused by stale REG_UNUSED note nvachhar at google dot com
                   ` (3 preceding siblings ...)
  2009-07-24 15:39 ` nvachhar at google dot com
@ 2009-07-24 17:05 ` steven at gcc dot gnu dot org
  2009-07-24 17:47 ` nvachhar at google dot com
  5 siblings, 0 replies; 9+ messages in thread
From: steven at gcc dot gnu dot org @ 2009-07-24 17:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from steven at gcc dot gnu dot org  2009-07-24 17:04 -------
Then we should write a new function, something like this in df.h perhaps:

/* Given an INSN, return a SET expression if the insn has only one
   SET whose SET_DEST is used.  If SET_DEST is memory, then the SET is
   assumed to be used somewhere, always.

   This means that:
   * If an insn has multiple SETs to only registers, but only one of those
     SETs is used, return that one set.
   * If an insn has multiple SETs to only registers, but none one of those
     SETs is used, return NULL_RTX.
   * If an insn has multiple SETs to registers and/or memory, but the SETs to
     registers are dead, return the one memory SET, or NULL_RTX if there are
     multiple sets to memory.

   Only accept INSNs.  single_set() can take a pattern, but that is 
   "old skool" style that should be abolished.

   May miss some single_set SETs that single_set() can find, because this
   function just looks for the number of uses of a register to determine
   whether a set is used (which may fail for hard registers and for unusual
   situations with pseudos that somehow are set twice but never used) whereas
   single_set() uses liveness information through REG_UNUSED notes.  Still,
   I expect that, in practice, this function works just as well as 
   single_set().

   One more caveat: The DF user must use incremental scanning, or the
   DF_REG_USE_COUNT may be wrong.  The result of df_single_set would be
   unconservative for new registers since the last scan (DF_REG_USE_COUNT
   will still be 0, indicating the new reg is unused and its SET can be
   ignored).  */

rtx
df_single_set (rtx insn)
{
  rtx pat;

  gcc_assert (INSN_P (insn));

  /* ??? Could even just fall back if the current DF mode is not incremental
         scanning.  */
  pat = PATTERN (insn);
  if (GET_CODE (pat) == SET)
    return pat;
  else if (GET_CODE (pat) == PARALLEL)
    {
      int i;
      rtx set = NULL_RTX;
      for (i = 0; i < XVECLEN (pat, 0); i++)
        {
          rtx sub = XVECEXP (pat, 0, i);
          switch (GET_CODE (sub))
          {
          case USE:
          case CLOBBER:
            break;

          case SET:
            if (! set)
              {
                rtx dest = SET_DEST (set);
                if (GET_CODE (dest) == SUBREG)
                  dest = SUBREG_REG (dest);
                if (! REG_P (dest)
                    || DF_REG_USE_COUNT (dest) > 0)
                  set = sub;
              }
            else
              return NULL_RTX;
            break;

          default:
            return NULL_RTX;
          }
        }
    }
  else
    return NULL_RTX;
}


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40209


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug rtl-optimization/40209] ICE in iv_analyze_def caused by stale REG_UNUSED note
  2009-05-20 18:47 [Bug rtl-optimization/40209] New: ICE in iv opts caused by stale REG_UNUSED note nvachhar at google dot com
                   ` (2 preceding siblings ...)
  2009-07-24  6:27 ` steven at gcc dot gnu dot org
@ 2009-07-24 15:39 ` nvachhar at google dot com
  2009-07-24 17:05 ` steven at gcc dot gnu dot org
  2009-07-24 17:47 ` nvachhar at google dot com
  5 siblings, 0 replies; 9+ messages in thread
From: nvachhar at google dot com @ 2009-07-24 15:39 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1352 bytes --]



------- Comment #5 from nvachhar at google dot com  2009-07-24 15:39 -------
Subject: Re:  ICE in iv_analyze_def caused by 
        stale REG_UNUSED note

loop-iv does need notes, albeit indirectly through the single_set
function.  single_set looks at the REG_UNUSED note, and if all but one
set have that note on it, then it asserts that a parallel set is a
single set.  I do agree that this problem is pervasive through gcc.
Any pass that uses single_set is implicitly a user of reg ntoes.

On Thu, Jul 23, 2009 at 11:27 PM, steven at gcc dot gnu dot
org<gcc-bugzilla@gcc.gnu.org> wrote:
>
>
> ------- Comment #4 from steven at gcc dot gnu dot org  2009-07-24 06:27 -------
> A hint, please, about why the patch of comment #2 would be the correct fix.  As
> far as I can tell, loop-iv doesn't need the notes and shouldn't have to clean
> up other passes' mess. This patch also introduces a pass ordering restriction
> that shouldn't be there. And at the very least, if this bug gets papered over
> like this, then there should be a comment in loop-iv that the problem is only
> added to fix bugs elsewhere...
>
>
> --
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40209
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40209


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug rtl-optimization/40209] ICE in iv_analyze_def caused by stale REG_UNUSED note
  2009-05-20 18:47 [Bug rtl-optimization/40209] New: ICE in iv opts caused by stale REG_UNUSED note nvachhar at google dot com
  2009-07-24  4:01 ` [Bug rtl-optimization/40209] ICE in iv_analyze_def " ian at gcc dot gnu dot org
  2009-07-24  6:25 ` ubizjak at gmail dot com
@ 2009-07-24  6:27 ` steven at gcc dot gnu dot org
  2009-07-24 15:39 ` nvachhar at google dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: steven at gcc dot gnu dot org @ 2009-07-24  6:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from steven at gcc dot gnu dot org  2009-07-24 06:27 -------
A hint, please, about why the patch of comment #2 would be the correct fix.  As
far as I can tell, loop-iv doesn't need the notes and shouldn't have to clean
up other passes' mess. This patch also introduces a pass ordering restriction
that shouldn't be there. And at the very least, if this bug gets papered over
like this, then there should be a comment in loop-iv that the problem is only
added to fix bugs elsewhere...


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40209


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug rtl-optimization/40209] ICE in iv_analyze_def caused by stale REG_UNUSED note
  2009-05-20 18:47 [Bug rtl-optimization/40209] New: ICE in iv opts caused by stale REG_UNUSED note nvachhar at google dot com
  2009-07-24  4:01 ` [Bug rtl-optimization/40209] ICE in iv_analyze_def " ian at gcc dot gnu dot org
@ 2009-07-24  6:25 ` ubizjak at gmail dot com
  2009-07-24  6:27 ` steven at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: ubizjak at gmail dot com @ 2009-07-24  6:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from ubizjak at gmail dot com  2009-07-24 06:25 -------
Please also add the testcase from Comment #1 to gcc testsuite.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40209


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug rtl-optimization/40209] ICE in iv_analyze_def caused by stale REG_UNUSED note
  2009-05-20 18:47 [Bug rtl-optimization/40209] New: ICE in iv opts caused by stale REG_UNUSED note nvachhar at google dot com
@ 2009-07-24  4:01 ` ian at gcc dot gnu dot org
  2009-07-24  6:25 ` ubizjak at gmail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: ian at gcc dot gnu dot org @ 2009-07-24  4:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from ian at gcc dot gnu dot org  2009-07-24 04:01 -------
Subject: Bug 40209

Author: ian
Date: Fri Jul 24 04:01:13 2009
New Revision: 150038

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150038
Log:
        PR rtl-optimization/40209
        * loop-iv.c (iv_analysis_loop_init): Call df_note_add_problem.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/loop-iv.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40209


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-12-06 18:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-40209-4@http.gcc.gnu.org/bugzilla/>
2023-12-06 18:32 ` [Bug rtl-optimization/40209] ICE in iv_analyze_def caused by stale REG_UNUSED note pinskia at gcc dot gnu.org
2023-12-06 18:33 ` pinskia at gcc dot gnu.org
2023-12-06 18:34 ` [Bug rtl-optimization/40209] stale REG_UNUSED note vs single_set pinskia at gcc dot gnu.org
2009-05-20 18:47 [Bug rtl-optimization/40209] New: ICE in iv opts caused by stale REG_UNUSED note nvachhar at google dot com
2009-07-24  4:01 ` [Bug rtl-optimization/40209] ICE in iv_analyze_def " ian at gcc dot gnu dot org
2009-07-24  6:25 ` ubizjak at gmail dot com
2009-07-24  6:27 ` steven at gcc dot gnu dot org
2009-07-24 15:39 ` nvachhar at google dot com
2009-07-24 17:05 ` steven at gcc dot gnu dot org
2009-07-24 17:47 ` nvachhar at google dot com

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).