This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

optimization/9276: Internal compiler error in reg-stack.c:


>Number:         9276
>Category:       optimization
>Synopsis:       Internal compiler error in reg-stack.c:
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Sat Jan 11 07:36:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Peter Smulders
>Release:        g77 / gcc version 3.2.1
>Organization:
>Environment:
Pentium4 processor (2.66 GHz) with Debian Linux 2.4.20
>Description:
When compiling a Fortran subroutine with
g77 version 3.2.1 I get the following error message:

  Internal compiler error in compensate_edge, at reg-stack.c:2591
  Please submit a full bug report,
  with preprocessed source if appropriate.
>How-To-Repeat:
g77 -v -save-temps -c -Wall -pedantic -O2 -dk buggy.f
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="bugreport"
Content-Disposition: inline; filename="bugreport"

When compiling a Fortran subroutine with
g77 version 3.2.1 I get the following error message:

  Internal compiler error in compensate_edge, at reg-stack.c:2591
  Please submit a full bug report,
  with preprocessed source if appropriate.
--------------------------------------------------------
system description:

output of g77 -v:
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/specs
Configured with: ../configure 
Thread model: posix
gcc version 3.2.1

gcc and g77 built with 'make bootstrap'

Pentium4 processor (2.66 GHz) with Debian Linux 2.4.20

--------------------------------------------------------
The software has been previously succesfully compiled 
with various Fortran compilers, including gcc 2.95.4 / g77 0.5.25.

The problem only appears with optimalization set at -O2 or
higher.

Attempts to locate the origin of this problem where
confusing. It is possible to get rid of the error message
by eliminating parts of the code. But many different ways of doing
so were observed!
The thing finally presented here as a "minimum case" is one where the
removal of on single line of code makes the problem go away.
It is a heavily stripped version of the original subroutine, and as 
such, not meaningful, but, syntactically correct.
--------------------------------------------------------
Some details about the error I found out myself.

It seems to occur in a module "reg-stack.c" of gcc.
In file "gcc-3.2.1/gcc/reg-stack.c"
we find around line 2591 the code:

   2587       /* We don't support abnormal edges.  Global takes care to
   2588          avoid any live register across them, so we should never
   2589          have to insert instructions on such edges.  */
   2590       if (e->flags & EDGE_ABNORMAL)
   2591         abort ();

The module reg-stack.c is also mentioned in one of the info files
(gccint.info-2, Node passes)
    * Conversion from usage of some hard registers to usage of a register
      stack may be done at this point.  Currently, this is supported only
      for the floating-point registers of the Intel 80387 coprocessor.
      The source file name is `reg-stack.c'.

      The options `-dk' causes a debugging dump of the RTL code after
      this pass.  This dump file's name is made by appending `.stack' to
      the input file name.

This file, buggy.f.28.stack, is obviously incomplete,
which confirms the error exit occurs during this pass.
--------------------------------------------------------
#!/bin/csh
# script used to generate the error

rm -f buggy.log

g77 -v -save-temps -c -Wall -pedantic -O2 -dk buggy.f \
|& tee buggy.log
 
 exit
--------------------------------------------------------
compiler output:
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/specs
Configured with: ../configure 
Thread model: posix
gcc version 3.2.1
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/f771 buggy.f -quiet -dumpbase buggy.f -dk -O2 -Wall -pedantic -version -o buggy.s
GNU F77 version 3.2.1 (i686-pc-linux-gnu)
	compiled by GNU C version 3.2.1.
buggy.f: In subroutine `bbloop':
buggy.f:227: warning: `__g77_do_26' might be used uninitialized in this function
buggy.f:260: warning: `__g77_do_32' might be used uninitialized in this function
buggy.f:290: Internal compiler error in compensate_edge, at reg-stack.c:2591
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
--------------------------------------------------------
source code, file buggy.f:
      SUBROUTINE BBLOOP(K)

      PARAMETER (NL=2,ML=NL*2,NLAYER=2,NANGMAX=2000)
      PARAMETER (NLTOT=NL*NLAYER, MLTOT=ML*NLAYER)

      PARAMETER ( NF=100, NV=100,  NBIN =1000, NEBIN=NBIN, MAXRAAK = 99)
      PARAMETER ( NTHICKMAX = 16)
      COMMON /COMDIM/ NFA,NVA,NLA(NLAYER),MLA,NBINA,NEBINA,NLAY

      CHARACTER*10 CONFIGID, CSYMM
      COMMON /CONFIG/ CONFIGID(NLAYER), CSYMM(NLAYER)
      COMMON /COMFIG/ NIND(NLAYER),
     + MODX(NLAYER),MODY(NLAYER),MODZ(NLAYER),
     + APC(NL,NLAYER),APC1(ML,NLAYER),NABUR(NL,NLAYER),LATTICE(NLAYER),
     + XPOS(24,NL,NLAYER),YPOS(24,NL,NLAYER),
     + DUNIT(3,NLAYER), XUNIT(3,NLAYER), YUNIT(3,NLAYER),
     + ZPOS(NL,NLAYER),
     + IATOM(0:15,1:NL,NLAYER), XATOM0(16,NLAYER), YATOM0(16,NLAYER),
     + IP(3,2,NLAYER) , NFX, NFY, NLC(NLAYER)

      COMMON /COMFLUX/ ANORM0(ML,NLAYER),ANORM(ML,NLAYER),NDELZ,ZMAX,
     + LFLX,NRAAK,ZSIG,FLUX(NF*NF),
     + RAAK(0:NBIN-1,ML,NLAYER),KRAAK(MAXRAAK),
     + DAV(0:NBIN-1,ML),DDAV(0:NBIN-1,ML)

      COMMON /COMCHAN/ RM(ML,NLAYER),TESQMAX,
     + U2SQ(ML,NLAYER),U2(ML,NLAYER),U1(ML,NLAYER),
     + XUN(NLAYER),YUN(NLAYER),UD(NLAYER),CELL(NLAYER),
     + XUM(NLAYER),YUM(NLAYER),XATOM(16,NLAYER),YATOM(16,NLAYER),
     + ZZ0,XSDR,YSDR,ANGR,TWOXUN(NLAYER),TWOYUN(NLAYER),NXI,NYI,DXI,DYI,
     + RSCREEN(ML,NLAYER), ZZA2(ML,NLAYER), ZZD2(ML,NLAYER), NBINF

      COMMON /COMINP/ T0,TMIN,Z1,Z2(ML,NLAYER),
     + A1,A2(ML,NLAYER),DEBYE(ML,NLAYER),TEMP,UA(3,NLAYER),
     + ZIMAX,ZIFWHM,XSD,YSD,ANGH,NSEED,NTRX,NRUN,NANG,ANG(3,NANGMAX),
     + IXYOUT, WEIGHTDE, CURPLANE, CURRADIUS(NLAYER), BEAMX, BEAMY

      COMMON /COMLOS/ DEDXVL(NLAYER), DEDXVP(NLAYER),
     + ELCORE(50,ML,NLAYER), DEVL(NLAYER), DEVP(NLAYER)

      COMMON /COMCROS/ NCROSS(0:ML,NLAYER),ECROSS(200,0:ML,NLAYER),
     +              CROSS(200,0:ML,NLAYER)
      COMMON /PROFILE/ PROFIEL(0:NBIN-1)

      LOGICAL JOPTION
      PARAMETER(NOPTION = 12)
      COMMON /FLXOPT/ JOPTION(NOPTION)
      PARAMETER(LFFLUX=1, LFVELO=2, LFNCHAN=3, LFSCORE=4, LFCOLLI=5,
     + LFEFINAL=6, LFXYOUT=7, LFEFILE=8, LEXITCO=9, LFCFILE=10, 
     + LSTARTCO=11, LMIXED=12 )
      COMMON /DBLAYER/ ZINTERF(NLAYER), WINTERF(NLAYER),
     + ROTM(3,3,NLAYER), TRANSL(3,NLAYER),THICK(NTHICKMAX), NTHICK,
     + EBIN, PBIN, NP0, AMAWBEAM, ROTI(3,3), TRANSI(3)
      COMMON /CURVATURE/ CURMAT(3,3,NLAYER), CURMATT(3,3,NLAYER)
      DOUBLE PRECISION TFINAL, DTFINAL, PXFINAL, DPXFINAL,
     +   PYFINAL, DPYFINAL, PTFINAL, DPTFINAL
      COMMON /COMFINAL/ TFINAL, DTFINAL, PXFINAL, DPXFINAL,
     +   PYFINAL, DPYFINAL, PTFINAL, DPTFINAL, NFINAL
      COMMON /XTRAPARM/
     + ANGPMAX, CRITX, CRITY,
     + ANGPMDG, CRITXDG, CRITYDG,
     + TFMIN, TFMAX
      COMMON /COMEXIT/ EFINAL(0:NEBIN),VFINAL(NV*NV)
      COMMON /XTRADATA/ 
     + NCHANNEL(0:NBIN-1), LEFTOVER(0:NBIN-1),
     + SNUCLEAR(0:NBIN-1), SCORE(0:NBIN-1), SVALENCE(0:NBIN-1)

      COMMON /ESPEC/ZVAL(NL,NLAYER),AVZVAL(NLAYER),TAPC(NLAYER),
     + E0,ES,RENRGY, ICRATE(0:2048),LOSS

      INTEGER NLA0, NLA1, ILMAP
      COMMON /MIXCOM/ ATOMFRAC(ML,NLAYER), HITLIST(3,NL,NLAYER),
     + NLA0(NLAYER), NLA1(NL,NLAYER), ILMAP(NL,NLAYER)

      PARAMETER(PI=3.14159265,TWOPI=2.0*PI,DEGREE=TWOPI/360.0)

      COMMON /COMPOTZ/ IZ2

      INTEGER INDIC(6)

      DOUBLE PRECISION  DAVDPR(0:NBIN-1,ML)
      DOUBLE PRECISION DDAVDPR(0:NBIN-1,ML)
      COMMON /DOUBLEDAV/DAVDPR, DDAVDPR

      TWOYUNKL=0
      KL=0
      JZ=0
      MODZKL=0
      T=0.0
      IL=0
      IL1=0
      NINDKL=0
      JIND=0

      DO 8 LX=1,NXI
      RLX=LX
      DO 88 LY=1,NYI
*** if the following IF .. ENDIF clause is removed
*** the problem disappears
      IF(JOPTION(LFCFILE))THEN
  248   call getcoord(LUN(4),0, XX, YY, PX, PY, TT, ier)
        if(ier .eq. 1) then
          goto 248
        else if(ier.ne.0) then
          goto 1234
        endif
      ENDIF
***
      DO 123 NZ=0,NBINF*NDELZ-1

*** but also eliminating the following part makes the
*** problem go away
      IF (NCROSS(1,KL).LT.0) THEN
        ASSIGN 510 TO LATIX1
      ELSE IF (NCROSS(1,KL).EQ.0) THEN
        ASSIGN 511 TO LATIX1
      ELSE
        ASSIGN 512 TO LATIX1
      ENDIF
      IF (NCROSS(2,KL).LT.0) THEN
        ASSIGN 510 TO LATIX2
      ELSE IF (NCROSS(2,KL).EQ.0) THEN
        ASSIGN 511 TO LATIX2
      ELSE
        ASSIGN 512 TO LATIX2
      ENDIF
      IF (NCROSS(3,KL).LT.0) THEN
        ASSIGN 510 TO LATIX3
      ELSE IF (NCROSS(3,KL).EQ.0) THEN
        ASSIGN 511 TO LATIX3
      ELSE
        ASSIGN 512 TO LATIX3
      ENDIF
      IF (NCROSS(4,KL).LT.0) THEN
        ASSIGN 510 TO LATIX4
      ELSE IF (NCROSS(4,KL).EQ.0) THEN
        ASSIGN 511 TO LATIX4
      ELSE
        ASSIGN 512 TO LATIX4
      ENDIF
***

*** also removing the following lengthy IF THEN ELSE get
*** rid of the problem
        IF ( LATTICE(KL) .EQ. 100 ) THEN
          ASSIGN 100 TO ISWITCH
        ELSE IF ( LATTICE(KL) .EQ. 2100 ) THEN
          ASSIGN 2100 TO ISWITCH
        ELSE IF ( LATTICE(KL) .EQ. 5100 ) THEN
          ASSIGN 5100 TO ISWITCH
        ELSE IF ( LATTICE(KL) .EQ. 110 ) THEN
          ASSIGN 110 TO ISWITCH
        ELSE IF ( LATTICE(KL) .EQ. 2110 ) THEN
          ASSIGN 2110 TO ISWITCH
        ELSE IF ( LATTICE(KL) .EQ. 3110 ) THEN
          ASSIGN 3110 TO ISWITCH
        ELSE IF ( LATTICE(KL) .EQ. 111 ) THEN
          ASSIGN 111 TO ISWITCH
        ELSE IF ( LATTICE(KL) .EQ. 2111 ) THEN
          ASSIGN 2111 TO ISWITCH
        ELSE IF ( LATTICE(KL) .EQ. 3111 ) THEN
          ASSIGN 3111 TO ISWITCH
        ELSE IF ( LATTICE(KL) .EQ. 4111 ) THEN
          ASSIGN 4111 TO ISWITCH
        ELSE IF ( LATTICE(KL) .EQ. 2211 ) THEN
          ASSIGN 2211 TO ISWITCH
        ELSE
          STOP 'BBLOOP: Unkown LATTICE type'
        ENDIF
***

         GOTO ISWITCH
  100 CONTINUE
      GOTO 7
  110 CONTINUE
      GOTO 7
 2100 CONTINUE
      GOTO 7
 3110 CONTINUE
      GOTO 7
 2110 CONTINUE
      GOTO 7
  111 CONTINUE
      GOTO 7
 2111 CONTINUE
      GOTO 7

 3111 CONTINUE
      GOTO 7
 4111 CONTINUE
      GOTO 7
 2211 CONTINUE
      GOTO 7
 5100 CONTINUE
*** eliminating the following line also gets rid of the problem
      YY = TWOYUNKL*2.0 - YY
***
      GOTO 7
60001 CONTINUE
      GOTO 7
  7      CONTINUE
      JZ = JZ - JZ/MODZKL*MODZKL
      IF ( JZ.LT.0 ) JZ = JZ + MODZKL

      IX = INT(XX/XUNKL*RNX) + 1
      IY = INT(YY/YUNKL*RNY) + 1

      IXIY=IX + (IY-1)*NFX
      TINV=1.0/T
      GOTO 509
  500 FLUX(IXIY) = FLUX(IXIY) + PROFIEL(IZ) * (TINV*T0)**2
      GOTO 509
  501 FLUX(IXIY) = FLUX(IXIY) + PROFIEL(IZ)
      GOTO 509
  502 FLUX(IXIY) = FLUX(IXIY) + PROFIEL(IZ) *
     +    CROSSECT( REAL(T), NCROSS(0,1), ECROSS(1,0,1), CROSS(1,0,1) )
      GOTO 509
  503 FLUX(IXIY) = FLUX(IXIY) +  (TINV*T0)**2
      GOTO 509
  504 FLUX(IXIY) = FLUX(IXIY) +  1.0
      GOTO 509
  505 FLUX(IXIY) = FLUX(IXIY) +
     +    CROSSECT( REAL(T), NCROSS(0,1), ECROSS(1,0,1), CROSS(1,0,1) )
  509 CONTINUE
      DECO=0.0
      DENU=0.0
      DO 6 IL=1,NL
        INDX=IATOM(JZ,IL,KL)
        IF(JOPTION(LMIXED))THEN
          IL1= ILMAP(IL,KL)
          CHANCE=URAND(ISEED) - ATOMFRAC(IL1,KL)
          IF(CHANCE .GE. 0)THEN
            IF(NLA1(IL,KL).gt.1)THEN
              IL1=1+IL1
              IF(CHANCE .GE. ATOMFRAC(IL1,KL))THEN
                HITLIST(3,IL,KL)= 1+HITLIST(3,IL,KL)
                GOTO 6
              ELSE
                HITLIST(2,IL,KL)= 1+HITLIST(2,IL,KL)
              ENDIF
            ELSE
              HITLIST(3,IL,KL)= 1+HITLIST(3,IL,KL)
              GOTO 6
            ENDIF
          ELSE
            HITLIST(1,IL,KL)= 1+HITLIST(1,IL,KL)
          ENDIF
	ELSE
          IL1= ILMAP(IL,KL)
	ENDIF
        LIND=0
  726   CONTINUE
        IF( INDX .GT. 0) THEN
          LIND= LIND+1
          INDXT= (INDX-1)/NINDKL
          INDIC(LIND)= INDX - (INDXT*NINDKL)
          INDX= INDXT
          GOTO 726
        ENDIF
        DO 599 JIND=1, LIND
        INDX= INDIC(JIND)
        XT= XATOM(INDX,KL) - XX
        YT= YATOM(INDX,KL) - YY
        RP= XT*PX + YT*PY
        S0= ( XT*XT + YT*YT -RP*RP ) / U2SQ(IL1,KL)
        IF (S0.GT.60.0) THEN
            CLENCY=0.0
        ELSE
            CLENCY=ANORM(IL1,KL) * EXP ( -S0)
            IF(IL1.eq.1)GOTO LATIX1
	    IF(IL1.eq.2)GOTO LATIX2
	    IF(IL1.eq.3)GOTO LATIX3
	    IF(IL1.eq.4)GOTO LATIX4
  510         CLENCY=CLENCY * (TINV*T0)**2
            GOTO 511
  512         CLENCY=CLENCY *
     +      CROSSECT(REAL(T), NCROSS(IL1,KL),
     +               ECROSS(1,IL1,KL), CROSS(1,IL1,KL))
  511         CONTINUE
        ENDIF
  599 CONTINUE
  6   CONTINUE

  123 CONTINUE

 8888 CONTINUE
  88  CONTINUE
  8   CONTINUE
 1234 CONTINUE
      END


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]