Constant pool madness.

Toon Moene toon@moene.indiv.nluug.nl
Sun Sep 2 03:14:00 GMT 2001


For some time now, g77 testsuite entry execute/19990826-2.f fails on
alpha with a time out.

The reason is that the compiler keeps circling around in the following
loop in varasm.c:

2103      /* Search the chain for an existing CONST_DOUBLE with the
right value.
2104         If one is found, return it.  */
2105      if (cfun != 0)
2106        for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
2107          if (CONST_DOUBLE_LOW (r) == i0 && CONST_DOUBLE_HIGH (r) ==
i1
2108              && GET_MODE (r) == mode)
2109            return r;

The reason for this seems to be that the sole floating point constant in
this program, 1.0e-5, first appears as a constant, but when it is
searched in this loop happens to be turned into a constant pool
addition:

$ gdb /usr/snp/lib/gcc-lib/alphaev6-unknown-linux-gnu/3.1/f771
...
(gdb) break varasm.c:2115
Breakpoint 1 at 0x1202a90e0: file ../../gcc/gcc/varasm.c, line 2115.
(gdb) run -O1 a.f
Starting program:
/usr/snp/lib/gcc-lib/alphaev6-unknown-linux-gnu/3.1/f771 -O1 a.f
 MAIN__ f1
Breakpoint 1, immed_double_const (i0=48, i1=3, mode=301904) at
../../gcc/gcc/varasm.c:2115
2115      if (current_function_decl != 0)
(gdb) p r
$1 = (struct rtx_def *) 0x20000049b30
(gdb) p debug_rtx(r)
(const_double:SF (const_int 0 [0x0]) 4532020583461814272
[0x3ee4f8b580000000] 0 [0x0] [9.999999747378752e-06])
$2 = void
...
(gdb) cont
Continuing.
^C
Program received signal SIGINT, Interrupt.
immed_double_const (i0=4532020583461814272, i1=0, mode=DFmode) at
../../gcc/gcc/varasm.c:2106
2106        for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
(gdb) p debug_rtx(r)
(const_double:SF (mem/u/f:SF (symbol_ref/u:DI ("*$LC2")) 0)
4532020583461814272 [0x3ee4f8b580000000] 0 [0x0]
[9.999999747378752e-06])
$4 = void
(gdb) quit
The program is running.  Exit anyway? (y or n) y
$

So for some reason:

1. The constant is changed to a pool constant after first being passed
   to immed_double_const.
2. The CONST_DOUBLE_CHAIN is corrupted because the for loop in line
   2106 never finishes.

Does anyone have any hints where to look for the real cause of this
problem ?

TIA,

-- 
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)



More information about the Gcc-bugs mailing list