gfortran fails with an internal error when the attached file is compiled with
-O3 optimization:

   error: edge from 62 to 64 should not be marked irreducible
   error: basic block 64 should not be marked irreducible
   error: edge from 64 to 53 should not be marked irreducible
   internal compiler error: in verify_loop_structure, at cfgloop.c:1268
   Please submit a full bug report,
   with preprocessed source if appropriate.
   See <URL:http://gcc.gnu.org/bugs.html> for instructions.

The error does not occur with -O2 optimization.

Comand line and output:
----------------
gfortran -v -c -O3 -std=legacy -fargument-alias -fno-backslash -fdollar-ok
-ffixed-line-length-72 -Wsurprising -Wuninitialized -W -fno-f2c pg3cl9.f
Using built-in specs.
Target: i386-apple-darwin8.7.1
Configured with: ../gcc-4.2-20060805/configure --enable-languages=fortran
Thread model: posix
gcc version 4.2.0 20060805 (experimental)
 /usr/local/libexec/gcc/i386-apple-darwin8.7.1/4.2.0/f951 pg3cl9.f -ffixed-form
-fPIC -quiet -dumpbase pg3cl9.f -mtune=i386 -auxbase pg3cl9 -O3 -Wsurprising
-Wuninitialized -W -std=legacy -version -fargument-alias -fno-backslash
-fdollar-ok -ffixed-line-length-72 -fno-f2c -I
/usr/local/lib/gcc/i386-apple-darwin8.7.1/4.2.0/finclude -o
/var/tmp//ccEAPkTX.s
GNU F95 version 4.2.0 20060805 (experimental) (i386-apple-darwin8.7.1)
        compiled by GNU C version 4.2.0 20060805 (experimental).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
pg3cl9.f: In function 'pg3cl9':
pg3cl9.f:214: error: edge from 62 to 64 should not be marked irreducible
pg3cl9.f:214: error: basic block 64 should not be marked irreducible
pg3cl9.f:214: error: edge from 64 to 53 should not be marked irreducible
pg3cl9.f:214: internal compiler error: in verify_loop_structure, at
cfgloop.c:1268
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
----------------

The legacy FORTRAN source file, pg3cl9.f
(This compiled with -O3 in g77)
C-----------------------------------------------------------------------
C ROUTINE:  PG3CL9
C PURPOSE:  To assign a new type to the line segs, and to decide
C           which lines are to be used in the resultant PG2-SET.
C
C ARGS:     NTOP         INTEGER pointer to the starting point
C                        of a polygon in the linked list
C           ID,XP,ZP     other PG3-SET
C           TYPE         INTEGER set operation type
C           ICURVE       INTEGER number of current PG2-SET
C                        1=A   2=B
C           XMN,ZMN,     REAL coordiantes of box of ID,XP,ZP.
C           XMX,ZMX
C           A,B,C,D      REAL*8 coefficients of equation of
C                        plane of ID,XP,YP,ZP.
C           IDS,XS,ZS    PG3-SET of edges being evaluated.
C           AS BS CS DS  REAL*8 coeficients of equation of
C                        plane of IDS,XS,YS,ZS.
C           NUMSEG       INTEGER number of segs looked at.
C           NUMADD       INTEGER number of segs added.
C-----------------------------------------------------------------------
      SUBROUTINE PG3CL9 (NTOP, ICURVE,
     +                   ID, XP,ZP, TYPE,
     +                   XMN,ZMN,XMX,ZMX,
     +                   A, B, C, D,
     +                   IDS,XS,ZS, TYPES,
     +                   AS,BS,CS,DS,
     +                   NUMSEG, NUMADD, *)
C
C Arguments.
      INTEGER    NTOP, ICURVE, ID(*), IDS(*), NUMSEG, NUMADD,
     +           TYPES, TYPE
      REAL*8     A,B,C,D, AS,BS,CS,DS
      REAL       XP(*),ZP(*), XS(*),ZS(*), XMN,ZMN, XMX,ZMX
C
C COMMON storage.
      INTEGER*4       NLNWMX, NPNWMX
      PARAMETER      (NLNWMX = 5000,
     +                NPNWMX = 5000)
C 
      COMMON /NW3SET/ LBNWA(NLNWMX), LENWA(NLNWMX),
     +                NLNWA, 
     +                PXNWA(NPNWMX), PYNWA(NPNWMX), PZNWA(NPNWMX),
     +                NPNWA,
     +                LBNWB(NLNWMX), LENWB(NLNWMX),
     +                NLNWB,
     +                PXNWB(NPNWMX), PYNWB(NPNWMX), PZNWB(NPNWMX),
     +                NPNWB, 
     +                LBNWC(NLNWMX), LENWC(NLNWMX),
     +                NLNWC,
     +                PXNWC(NPNWMX), PYNWC(NPNWMX), PZNWC(NPNWMX),
     +                NPNWC
      INTEGER*4       LBNWA, LENWA, NLNWA, NPNWA,
     +                LBNWB, LENWB, NLNWB, NPNWB,
     +                LBNWC, LENWC, NLNWC, NPNWC
      REAL*4          PXNWA, PYNWA, PZNWA,
     +                PXNWB, PYNWB, PZNWB,
     +                PXNWC, PYNWC, PZNWC
C
      INTEGER*4       NPMAX, NDMAX
      PARAMETER      (NPMAX = 5000,
     +                NDMAX = 5000)
C                         
      INTEGER*4       NPOINT
      REAL*4          X, Y, Z
      LOGICAL*4       INT 
      COMMON /TWOPT/  NPOINT,
     +                X(NPMAX), Y(NPMAX), Z(NPMAX), INT(NPMAX)
C
      INTEGER*4       NNODE, NODE
      COMMON /TWOND/  NNODE,
     +                NODE(6,NDMAX)
C
      REAL*4          XM1, YM1, XM2, YM2, XM3, YM3, XM4, YM4
      COMMON /TWOBOX/ XM1, YM1, XM2, YM2, XM3, YM3, XM4, YM4
C
      LOGICAL*4       DEBUG
      COMMON /TWODEB/ DEBUG
C
      REAL*4          TOL
      COMMON /TWOTOL/ TOL
C
      INTEGER*4     NLNMAX  
      PARAMETER    (NLNMAX = 1000) 
C
      LOGICAL*4     LNSW, ALLSW
      INTEGER*4     LIMIT, NLN1, LB1, LE1, NLN2, LB2, LE2
C
      COMMON /HSW/  LNSW(2), LIMIT, ALLSW(2),
     +              NLN1, LB1(NLNMAX), LE1(NLNMAX),
     +              NLN2, LB2(NLNMAX), LE2(NLNMAX)
C
C Local variables.
      INTEGER    OTHER(2), N, N1, N2, N3, N4, I1, I2,
     +           LTYPE, SOLID, WIRE
      REAL       Y2, XHALF, YHALF, YHALF1, YHALF2, ZHALF
      LOGICAL    PT2IPG, BX2TST, ADDSW
      DATA       OTHER /2, 1/
      DATA       SOLID/0/, WIRE/1/
C
C Other PG3-SET must be solid.
      IF (TYPE.EQ.WIRE) RETURN
C
C First line starts here.
      N = NTOP
      GO TO 9
C
C All other lines start here.
    8 IF (INT(NODE(1,N)))       GO TO 9
      IF (ADDSW.AND.LTYPE.EQ.3) GO TO 11
      IF (ADDSW.AND.LTYPE.EQ.2) GO TO 15
      IF (ADDSW)                GO TO 14
      GO TO 11
C
    9 ADDSW = .FALSE.
      IF (NODE(2,N).EQ.3 .OR. NODE(2,N).EQ.4) THEN
C
C TYPE=3   Parallel line segments.
         NODE(2,N) = 3
         N1        = NODE(1,NODE(4,N))
         IF (LNSW(OTHER(ICURVE))) GO TO 12
         N2        = NODE(1,NODE(4,NODE(3,N)))
         N3        = NODE(1,NODE(5,NODE(3,N)))
         N4        = NODE(1,NODE(3,N))
C
C ONEWAY TYPE=3 (running in same direction.)
         IF ((X(N1).EQ.X(N2)) .AND.
     +       (Z(N1).EQ.Z(N2))) THEN
            YHALF1 = (Y(N) +Y(N1))/2.
            YHALF2 = (Y(N4)+Y(N2))/2.
            IF (YHALF2.GT.YHALF1+TOL) GO TO 12
            IF (YHALF1.GT.YHALF2+TOL) GO TO 11
C
C Polygons touch and overlap.
            N3 = NODE(1,NODE(4,NODE(4,N)))
            Y2 = -(A*X(N3)+C*Z(N3)+D)/B
            IF (ABS(Y2-Y(N3)).LE.TOL) THEN
               N3 = NODE(1,NODE(4,NODE(4,NODE(4,N))))
               Y2 = -(A*X(N3)+C*Z(N3)+D)/B
            ENDIF
            IF (Y2.LT.Y(N3)) GO TO 11
            GO TO 12
C
C TWOWAY TYPE=3 (Running in opposite directions.)
         ELSE IF ((X(N1).EQ.X(N3)) .AND.
     +            (Z(N1).EQ.Z(N3))) THEN
             GO TO 12
C            YHALF1 = (Y(N) +Y(N1))/2.
C            YHALF2 = (Y(N4)+Y(N3))/2.
C            IF (YHALF2.GT.YHALF1+TOL) GO TO 12
C            IF (YHALF1.GT.YHALF2+TOL) GO TO 11
         ENDIF
      ENDIF
C
C TYPE=1. Is line segment outside other PG3-SET?
      NODE(2,N) = 1
      IF (LNSW(OTHER(ICURVE))) GO TO 12
      I1        = NODE(1,NODE(4,N))
      I2        = NODE(1,N)
      IF (.NOT.BX2TST(XMN,ZMN,XMX,ZMX,
     +                X(I1),Z(I1),X(I2),Z(I2),TOL)) GO TO 12
      XHALF = (DBLE(X(I1))+DBLE(X(I2)))/2.
      ZHALF = (DBLE(Z(I1))+DBLE(Z(I2)))/2.
      IF (PT2IPG(ID,XP,ZP,XHALF,ZHALF,TOL/2.)) GO TO 13
C
   12 LTYPE = 1
      GO TO 14
C
C TYPE=2.  Segment inside other PG3-SET.  Is it hidden?
   13 NODE(2,N) = 2
      ADDSW     = .TRUE.
      YHALF     = (Y(I1)+Y(I2))/2.
      Y2        = -(A*XHALF+C*ZHALF+D)/B
      LTYPE     = 3
      IF (Y2.LT.YHALF-TOL)      GO TO 11
      IF (ABS(Y2-YHALF).LE.TOL) THEN
C
C Line falls on other PG3-SET.
         IF (TYPES.EQ.SOLID) THEN
            IF (ABS(X(I1)-X(I2)).GE.ABS(Z(I1)-Z(I2))) THEN
               CALL PG3C9B (IDS,XS,ZS,XHALF,ZHALF,ZIN,TOL,*99)
               YHALF1 = (DS-(AS*XHALF+CS*ZIN))/BS
               YHALF2 = (D -(A *XHALF+C *ZIN))/B
            ELSE
               CALL PG3C9B (IDS,ZS,XS,ZHALF,XHALF,XIN,TOL,*99)
               YHALF1 = (DS-(AS*XIN+CS*ZHALF))/BS
               YHALF2 = (D -(A *XIN+C *ZHALF))/B
            ENDIF
            IF (YHALF2.LE.YHALF1-TOL) GO TO 11
         ENDIF
      ENDIF
      LTYPE = 2
C
C Line is to be added.
   15 IF (NODE(3,NODE(4,N)) .EQ. 0)
     +   CALL PG3C9A (NODE(4,N), A, B, C, D)
      IF (NODE(3,N) .EQ. 0)
     +   CALL PG3C9A (N, A, B, C, D)
C
   14 ADDSW  = .TRUE.
      CALL PG3CL0 (LTYPE,N,ICURVE,*99)
      NUMADD = NUMADD+1
C
C Get next segment.
   11 NUMSEG = NUMSEG+1
      N      = NODE(4,N)
      IF (N.EQ.NTOP .OR. NODE(4,N).EQ.0) RETURN
      IF (NUMSEG.GT.LIMIT) RETURN
      GO TO 8
C
C Error return.
   99 RETURN 1
      END


-- 
           Summary: internal compiler error: in verify_loop_structure, at
                    cfgloop.c:1268
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: twhall at twhall dot com
  GCC host triplet: i386-apple-darwin8.7.1 (Intel Core Duo, MacBook, Mac OS
                    X 10.4.7
GCC target triplet: i386-apple-darwin8.7.1


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

Reply via email to