public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/17926] New: infinite loop in LAPACK test at -Os and -O2
@ 2004-10-10 23:49 tobi at gcc dot gnu dot org
  2004-10-10 23:50 ` [Bug middle-end/17926] " tobi at gcc dot gnu dot org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-10-10 23:49 UTC (permalink / raw)
  To: gcc-bugs

The LAPACK test slarrv.f ends up in an infinite loop, when compiled with -Os or
-O2. Closer look at the assembly reveals that we're inddeed generating an
infinite loop.

The relevant parts form the loop looks something like this:
   40    CONTINUE
         IF( NDONE.LT.IM ) THEN
            OLDNCL = NCLUS
            NCLUS = 0
            LSBDPT = 1 - LSBDPT
            DO 150 I = 1, OLDNCL
                ....
            150       CONTINUE
            NDEPTH = NDEPTH + 1
            GO TO 40
         END IF
And in the -Os assembly (I have the patch from PR17560 in tree in order to build
some other files from LAPACK with -Os):
   40    CONTINUE
         IF( NDONE.LT.IM ) THEN
 2ab:   8b bd 48 ff ff ff       mov    0xffffff48(%ebp),%edi
 2b1:   3b 7d ec                cmp    0xffffffec(%ebp),%edi
 2b4:   0f 8d 25 0a 00 00       jge    cdf <slarrv_+0xcdf>
          ....
            OLDNCL = NCLUS
            NCLUS = 0
            LSBDPT = 1 - LSBDPT
            DO 150 I = 1, OLDNCL
 2ba:   83 bd 3c ff ff ff 00    cmpl   $0x0,0xffffff3c(%ebp)
 2c1:   c7 45 ac 00 00 00 00    movl   $0x0,0xffffffac(%ebp)
 2c8:   0f 8e fd 09 00 00       jle    ccb <slarrv_+0xccb>
 2ce:   c7 45 b0 01 00 00 00    movl   $0x1,0xffffffb0(%ebp)
          ...
 ccb:   8b 45 ac                mov    0xffffffac(%ebp),%eax
 cce:   ff 85 44 ff ff ff       incl   0xffffff44(%ebp)
 cd4:   89 85 3c ff ff ff       mov    %eax,0xffffff3c(%ebp)
 cda:   e9 cc f5 ff ff          jmp    2ab <slarrv_+0x2ab>
  140          CONTINUE
  150       CONTINUE
            NDEPTH = NDEPTH + 1
            GO TO 40
         END IF

(gfortran doesn't output debug information for the end do statements, that's why
they appear after the relevant code)

If you look closely enough, you'll see the infinite loop: the condition at 2b4
can never be true if the jump at 2c8 is taken.

If anybody has good ideas on reducing the testcase, I'm all ears. I'll attach
the source file, and the output from objdump -s

-- 
           Summary: infinite loop in LAPACK test at -Os and -O2
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tobi at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug middle-end/17926] infinite loop in LAPACK test at -Os and -O2
  2004-10-10 23:49 [Bug middle-end/17926] New: infinite loop in LAPACK test at -Os and -O2 tobi at gcc dot gnu dot org
@ 2004-10-10 23:50 ` tobi at gcc dot gnu dot org
  2004-10-10 23:51 ` tobi at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-10-10 23:50 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2004-10-10 23:50 -------
Created an attachment (id=7319)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7319&action=view)
LAPACK source file which shows the infinite loop


-- 


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


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

* [Bug middle-end/17926] infinite loop in LAPACK test at -Os and -O2
  2004-10-10 23:49 [Bug middle-end/17926] New: infinite loop in LAPACK test at -Os and -O2 tobi at gcc dot gnu dot org
  2004-10-10 23:50 ` [Bug middle-end/17926] " tobi at gcc dot gnu dot org
@ 2004-10-10 23:51 ` tobi at gcc dot gnu dot org
  2004-10-10 23:52 ` tobi at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-10-10 23:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2004-10-10 23:51 -------
Created an attachment (id=7320)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7320&action=view)
output of objdump -s


-- 


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


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

* [Bug middle-end/17926] infinite loop in LAPACK test at -Os and -O2
  2004-10-10 23:49 [Bug middle-end/17926] New: infinite loop in LAPACK test at -Os and -O2 tobi at gcc dot gnu dot org
  2004-10-10 23:50 ` [Bug middle-end/17926] " tobi at gcc dot gnu dot org
  2004-10-10 23:51 ` tobi at gcc dot gnu dot org
@ 2004-10-10 23:52 ` tobi at gcc dot gnu dot org
  2004-10-10 23:56 ` pinskia at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-10-10 23:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2004-10-10 23:52 -------
(In reply to comment #0)
> The relevant parts form the loop looks something like this:
>    40    CONTINUE
>          IF( NDONE.LT.IM ) THEN
>             OLDNCL = NCLUS
>             NCLUS = 0
>             LSBDPT = 1 - LSBDPT
>             DO 150 I = 1, OLDNCL
>                 ....
                  ^^^^ nothing ommitted here
>             150       CONTINUE


-- 


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


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

* [Bug middle-end/17926] infinite loop in LAPACK test at -Os and -O2
  2004-10-10 23:49 [Bug middle-end/17926] New: infinite loop in LAPACK test at -Os and -O2 tobi at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2004-10-10 23:52 ` tobi at gcc dot gnu dot org
@ 2004-10-10 23:56 ` pinskia at gcc dot gnu dot org
  2004-10-11  0:01 ` tobi at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-10 23:56 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-10 23:56 -------
Does -fno-ivopts help?

-- 


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


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

* [Bug middle-end/17926] infinite loop in LAPACK test at -Os and -O2
  2004-10-10 23:49 [Bug middle-end/17926] New: infinite loop in LAPACK test at -Os and -O2 tobi at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2004-10-10 23:56 ` pinskia at gcc dot gnu dot org
@ 2004-10-11  0:01 ` tobi at gcc dot gnu dot org
  2004-10-11  0:09 ` tobi at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-10-11  0:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2004-10-11 00:01 -------
One more thing I should add: I have a patch in tree which makes gfortran output
sensible debug information for loops. This patch has been already posted
http://gcc.gnu.org/ml/fortran/2004-10/msg00073.html

I actually wrote that patch to be able to debug this problem, so you might find
it helpful as well :-)

-- 


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


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

* [Bug middle-end/17926] infinite loop in LAPACK test at -Os and -O2
  2004-10-10 23:49 [Bug middle-end/17926] New: infinite loop in LAPACK test at -Os and -O2 tobi at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2004-10-11  0:01 ` tobi at gcc dot gnu dot org
@ 2004-10-11  0:09 ` tobi at gcc dot gnu dot org
  2004-10-11  0:12 ` tobi at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-10-11  0:09 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2004-10-11 00:09 -------
(In reply to comment #4)
> Does -fno-ivopts help?

Yes. recompiling slarrv.f with '-Os -fno-ivopts -g' fixed this.



-- 


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


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

* [Bug middle-end/17926] infinite loop in LAPACK test at -Os and -O2
  2004-10-10 23:49 [Bug middle-end/17926] New: infinite loop in LAPACK test at -Os and -O2 tobi at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2004-10-11  0:09 ` tobi at gcc dot gnu dot org
@ 2004-10-11  0:12 ` tobi at gcc dot gnu dot org
  2004-10-11  0:28 ` [Bug middle-end/17926] [4.0 Regression] " pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-10-11  0:12 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2004-10-11 00:12 -------
BTW, afaics it is surprising that -fno-ivopts fixes this, as the infinite loop
problem had been present even before Paul rewrote code generation for loops to
allow better loop optimization.

-- 


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


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

* [Bug middle-end/17926] [4.0 Regression] infinite loop in LAPACK test at -Os and -O2
  2004-10-10 23:49 [Bug middle-end/17926] New: infinite loop in LAPACK test at -Os and -O2 tobi at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2004-10-11  0:12 ` tobi at gcc dot gnu dot org
@ 2004-10-11  0:28 ` pinskia at gcc dot gnu dot org
  2004-10-26 22:34 ` rakdver at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-11  0:28 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-11 00:28 -------
Zdenek could you look into this since -fno-ivopts makes it works?

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rakdver at gcc dot gnu dot
                   |                            |org
            Summary|infinite loop in LAPACK test|[4.0 Regression] infinite
                   |at -Os and -O2              |loop in LAPACK test at -Os
                   |                            |and -O2
   Target Milestone|---                         |4.0.0


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


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

* [Bug middle-end/17926] [4.0 Regression] infinite loop in LAPACK test at -Os and -O2
  2004-10-10 23:49 [Bug middle-end/17926] New: infinite loop in LAPACK test at -Os and -O2 tobi at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2004-10-11  0:28 ` [Bug middle-end/17926] [4.0 Regression] " pinskia at gcc dot gnu dot org
@ 2004-10-26 22:34 ` rakdver at gcc dot gnu dot org
  2004-10-27 16:27 ` tobi at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rakdver at gcc dot gnu dot org @ 2004-10-26 22:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rakdver at gcc dot gnu dot org  2004-10-26 22:34 -------
Tobias, would it be possible to get a smaller testcase?
Ideally a runnable one, but if it would be too much trouble, at least one from
that as much of irrelevant code as possible is removed, while still preserving
the misscompilation?  I am not very familiar with fortran, so it would be quite
difficult for me :-(

-- 


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


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

* [Bug middle-end/17926] [4.0 Regression] infinite loop in LAPACK test at -Os and -O2
  2004-10-10 23:49 [Bug middle-end/17926] New: infinite loop in LAPACK test at -Os and -O2 tobi at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2004-10-26 22:34 ` rakdver at gcc dot gnu dot org
@ 2004-10-27 16:27 ` tobi at gcc dot gnu dot org
  2004-11-08 23:25 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-10-27 16:27 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2004-10-27 16:27 -------
I'll see if I can reduce it a little.

-- 


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


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

* [Bug middle-end/17926] [4.0 Regression] infinite loop in LAPACK test at -Os and -O2
  2004-10-10 23:49 [Bug middle-end/17926] New: infinite loop in LAPACK test at -Os and -O2 tobi at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2004-10-27 16:27 ` tobi at gcc dot gnu dot org
@ 2004-11-08 23:25 ` pinskia at gcc dot gnu dot org
  2004-11-11 20:14 ` rakdver at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-08 23:25 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |17742


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


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

* [Bug middle-end/17926] [4.0 Regression] infinite loop in LAPACK test at -Os and -O2
  2004-10-10 23:49 [Bug middle-end/17926] New: infinite loop in LAPACK test at -Os and -O2 tobi at gcc dot gnu dot org
                   ` (10 preceding siblings ...)
  2004-11-08 23:25 ` pinskia at gcc dot gnu dot org
@ 2004-11-11 20:14 ` rakdver at gcc dot gnu dot org
  2004-11-11 20:17 ` pinskia at gcc dot gnu dot org
  2004-11-27  6:13 ` pinskia at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: rakdver at gcc dot gnu dot org @ 2004-11-11 20:14 UTC (permalink / raw)
  To: gcc-bugs



-- 
Bug 17926 depends on bug 17742, which changed state.

Bug 17742 Summary: [4.0 Regression] C Optimization error with -O1 on i686
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17742

           What    |Old Value                   |New Value
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

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


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

* [Bug middle-end/17926] [4.0 Regression] infinite loop in LAPACK test at -Os and -O2
  2004-10-10 23:49 [Bug middle-end/17926] New: infinite loop in LAPACK test at -Os and -O2 tobi at gcc dot gnu dot org
                   ` (11 preceding siblings ...)
  2004-11-11 20:14 ` rakdver at gcc dot gnu dot org
@ 2004-11-11 20:17 ` pinskia at gcc dot gnu dot org
  2004-11-27  6:13 ` pinskia at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-11 20:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-11 20:16 -------
Can you try this again as PR 17742 is now fixed?

-- 


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


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

* [Bug middle-end/17926] [4.0 Regression] infinite loop in LAPACK test at -Os and -O2
  2004-10-10 23:49 [Bug middle-end/17926] New: infinite loop in LAPACK test at -Os and -O2 tobi at gcc dot gnu dot org
                   ` (12 preceding siblings ...)
  2004-11-11 20:17 ` pinskia at gcc dot gnu dot org
@ 2004-11-27  6:13 ` pinskia at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-27  6:13 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-27 06:13 -------
This is also fixed now.

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


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


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

end of thread, other threads:[~2004-11-27  6:13 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-10 23:49 [Bug middle-end/17926] New: infinite loop in LAPACK test at -Os and -O2 tobi at gcc dot gnu dot org
2004-10-10 23:50 ` [Bug middle-end/17926] " tobi at gcc dot gnu dot org
2004-10-10 23:51 ` tobi at gcc dot gnu dot org
2004-10-10 23:52 ` tobi at gcc dot gnu dot org
2004-10-10 23:56 ` pinskia at gcc dot gnu dot org
2004-10-11  0:01 ` tobi at gcc dot gnu dot org
2004-10-11  0:09 ` tobi at gcc dot gnu dot org
2004-10-11  0:12 ` tobi at gcc dot gnu dot org
2004-10-11  0:28 ` [Bug middle-end/17926] [4.0 Regression] " pinskia at gcc dot gnu dot org
2004-10-26 22:34 ` rakdver at gcc dot gnu dot org
2004-10-27 16:27 ` tobi at gcc dot gnu dot org
2004-11-08 23:25 ` pinskia at gcc dot gnu dot org
2004-11-11 20:14 ` rakdver at gcc dot gnu dot org
2004-11-11 20:17 ` pinskia at gcc dot gnu dot org
2004-11-27  6:13 ` pinskia 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).