This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/17926] New: infinite loop in LAPACK test at -Os and -O2
- From: "tobi at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Oct 2004 23:49:26 -0000
- Subject: [Bug middle-end/17926] New: infinite loop in LAPACK test at -Os and -O2
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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