public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/13521] New: Endless loop in calculate_global_regs_live
@ 2003-12-30 15:36 jakub at gcc dot gnu dot org
  2003-12-30 20:01 ` [Bug optimization/13521] [3.3 only] " pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: jakub at gcc dot gnu dot org @ 2003-12-30 15:36 UTC (permalink / raw)
  To: gcc-bugs

Following testcase at -O2 and higher loops forever in calculate_global_regs_live.
extern int f1 (int, void *);
extern int *f2 (void) __attribute__ ((__const__));
extern int f3 (int, void *);

int
test (int x, char *y, int z)
{
  int b = 0;

  if (x < 1024)
    {
      y[0] = '\0';

      do
        {
          switch (f1 (x, y + b))
            {
            case -1:
              if (b == 0)
                return -1;
              else
                return b;

            default:
              b++;
            }
        }
      while (y[b - 1] != '\0' && y[b - 1] != '\n' && b < z);
    }
  else
    {
      do
        {
          switch (f3 (x, y + b))
            {
            case -1:
              if ((*f2 ()) == 4)
                continue;
              if (b == 0)
                return -1;
              else
                return b;

            default:
              b++;
            }
        }
      while (y[b - 1] != '\0' && y[b - 1] != '\n' && b < z);
    }
  return b;
}

The problem seems to be that 1) cse finds out that the -1 constant in both return -1;
statements is already in the pseudo holding return value of f1() resp. f3()
and changes (set (reg:SI X) (const_int -1)) to (set (reg:SI X) (reg:SI Y)) REG_EQUAL (const_int -1).
2) during reload, this pseudo (Y above) is %eax after f1() and %r14d after f3()
(as in the latter case there is another function call in between)
3) during flow2 GCC replaces the pseudo with REG_EQUAL, so it is again:
(set (reg:SI %edx) (const_int -1)) REG_DEAD %r14d REG_EQUAL (const_int -1)
(in the f3() case and then merges both return -1's together).
The problem is REG_DEAD %r14d now, because it is set only in one of the predecessors
of the merged basic block, which causes the endless loop in calculate_global_regs_live
(as it keeps alternating between having %r14 live and not having it live).
Should cfg* not attempt to merge if there are different REG_DEAD notes
or do you have other ideas?

-- 
           Summary: Endless loop in calculate_global_regs_live
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org,jh at suse dot cz,rth at
                    redhat dot com
 GCC build triplet: *-*-*
  GCC host triplet: *-*-*
GCC target triplet: x86_64-redhat-linux


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


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

* [Bug optimization/13521] [3.3 only] Endless loop in calculate_global_regs_live
  2003-12-30 15:36 [Bug optimization/13521] New: Endless loop in calculate_global_regs_live jakub at gcc dot gnu dot org
@ 2003-12-30 20:01 ` pinskia at gcc dot gnu dot org
  2003-12-30 20:04 ` ebotcazou at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-30 20:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-30 19:38 -------
It does not happen on the mainline though.  I do not think this will ever be fixed for 3.3.3 though.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
            Summary|Endless loop in             |[3.3 only] Endless loop in
                   |calculate_global_regs_live  |calculate_global_regs_live


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


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

* [Bug optimization/13521] [3.3 only] Endless loop in calculate_global_regs_live
  2003-12-30 15:36 [Bug optimization/13521] New: Endless loop in calculate_global_regs_live jakub at gcc dot gnu dot org
  2003-12-30 20:01 ` [Bug optimization/13521] [3.3 only] " pinskia at gcc dot gnu dot org
@ 2003-12-30 20:04 ` ebotcazou at gcc dot gnu dot org
  2003-12-30 20:06 ` ebotcazou at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2003-12-30 20:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From ebotcazou at gcc dot gnu dot org  2003-12-30 19:43 -------
For another example of endless loop in c_g_r_l see PR opt/12158.


-- 


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


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

* [Bug optimization/13521] [3.3 only] Endless loop in calculate_global_regs_live
  2003-12-30 15:36 [Bug optimization/13521] New: Endless loop in calculate_global_regs_live jakub at gcc dot gnu dot org
  2003-12-30 20:01 ` [Bug optimization/13521] [3.3 only] " pinskia at gcc dot gnu dot org
  2003-12-30 20:04 ` ebotcazou at gcc dot gnu dot org
@ 2003-12-30 20:06 ` ebotcazou at gcc dot gnu dot org
  2003-12-31 15:05 ` jakub at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2003-12-30 20:06 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu dot
                   |                            |org


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


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

* [Bug optimization/13521] [3.3 only] Endless loop in calculate_global_regs_live
  2003-12-30 15:36 [Bug optimization/13521] New: Endless loop in calculate_global_regs_live jakub at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2003-12-30 20:06 ` ebotcazou at gcc dot gnu dot org
@ 2003-12-31 15:05 ` jakub at gcc dot gnu dot org
  2003-12-31 17:31 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu dot org @ 2003-12-31 15:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jakub at gcc dot gnu dot org  2003-12-31 11:59 -------
Fixed on mainline with:
http://gcc.gnu.org/ml/gcc-patches/2003-04/msg01324.html
Will post to gcc-patches.

-- 


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


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

* [Bug optimization/13521] [3.3 only] Endless loop in calculate_global_regs_live
  2003-12-30 15:36 [Bug optimization/13521] New: Endless loop in calculate_global_regs_live jakub at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2003-12-31 15:05 ` jakub at gcc dot gnu dot org
@ 2003-12-31 17:31 ` pinskia at gcc dot gnu dot org
  2004-01-01 13:19 ` cvs-commit at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-31 17:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-31 16:06 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02314.html>.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |patch
   Last reconfirmed|0000-00-00 00:00:00         |2003-12-31 16:06:09
               date|                            |
   Target Milestone|---                         |3.3.3


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


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

* [Bug optimization/13521] [3.3 only] Endless loop in calculate_global_regs_live
  2003-12-30 15:36 [Bug optimization/13521] New: Endless loop in calculate_global_regs_live jakub at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2003-12-31 17:31 ` pinskia at gcc dot gnu dot org
@ 2004-01-01 13:19 ` cvs-commit at gcc dot gnu dot org
  2004-01-01 13:21 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-01-01 13:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-01-01 13:19 -------
Subject: Bug 13521

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	jakub@gcc.gnu.org	2004-01-01 13:19:41

Modified files:
	gcc            : ChangeLog cfgcleanup.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/compile: 20031231-1.c 

Log message:
	PR optimization/13521
	Backport from mainline:
	2003-03-22  Richard Henderson <rth@redhat.com>
	
	* cfgcleanup.c (insns_match_p): Do not do EQUIV substitution
	after reload.
	
	* gcc.c-torture/compile/20031231-1.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.865&r2=1.16114.2.866
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cfgcleanup.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.68.2.8&r2=1.68.2.9
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.349&r2=1.2261.2.350
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/compile/20031231-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1



-- 


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


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

* [Bug optimization/13521] [3.3 only] Endless loop in calculate_global_regs_live
  2003-12-30 15:36 [Bug optimization/13521] New: Endless loop in calculate_global_regs_live jakub at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2004-01-01 13:19 ` cvs-commit at gcc dot gnu dot org
@ 2004-01-01 13:21 ` cvs-commit at gcc dot gnu dot org
  2004-01-01 15:32 ` pinskia at gcc dot gnu dot org
  2004-03-03 12:54 ` ebotcazou at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-01-01 13:21 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-01-01 13:21 -------
Subject: Bug 13521

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	jakub@gcc.gnu.org	2004-01-01 13:21:18

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/compile: 20031231-1.c 

Log message:
	PR optimization/13521
	* gcc.c-torture/compile/20031231-1.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3327&r2=1.3328
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/compile/20031231-1.c.diff?cvsroot=gcc&r1=1.1&r2=1.2



-- 


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


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

* [Bug optimization/13521] [3.3 only] Endless loop in calculate_global_regs_live
  2003-12-30 15:36 [Bug optimization/13521] New: Endless loop in calculate_global_regs_live jakub at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2004-01-01 13:21 ` cvs-commit at gcc dot gnu dot org
@ 2004-01-01 15:32 ` pinskia at gcc dot gnu dot org
  2004-03-03 12:54 ` ebotcazou at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-01 15:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-01 15:32 -------
Fixed for 3.3.3 and already for 3.4.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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


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

* [Bug optimization/13521] [3.3 only] Endless loop in calculate_global_regs_live
  2003-12-30 15:36 [Bug optimization/13521] New: Endless loop in calculate_global_regs_live jakub at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2004-01-01 15:32 ` pinskia at gcc dot gnu dot org
@ 2004-03-03 12:54 ` ebotcazou at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2004-03-03 12:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From ebotcazou at gcc dot gnu dot org  2004-03-03 12:54 -------
*** Bug 14335 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |r dot s dot a dot vandomburg
                   |                            |at student dot utwente dot
                   |                            |nl


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


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

end of thread, other threads:[~2004-03-03 12:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-30 15:36 [Bug optimization/13521] New: Endless loop in calculate_global_regs_live jakub at gcc dot gnu dot org
2003-12-30 20:01 ` [Bug optimization/13521] [3.3 only] " pinskia at gcc dot gnu dot org
2003-12-30 20:04 ` ebotcazou at gcc dot gnu dot org
2003-12-30 20:06 ` ebotcazou at gcc dot gnu dot org
2003-12-31 15:05 ` jakub at gcc dot gnu dot org
2003-12-31 17:31 ` pinskia at gcc dot gnu dot org
2004-01-01 13:19 ` cvs-commit at gcc dot gnu dot org
2004-01-01 13:21 ` cvs-commit at gcc dot gnu dot org
2004-01-01 15:32 ` pinskia at gcc dot gnu dot org
2004-03-03 12:54 ` ebotcazou at gcc dot gnu dot org

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