Debugging f-torture/execute/20000503-1.f failure

Billinghurst, David (CRTS) David.Billinghurst@riotinto.com.au
Fri Jun 30 18:56:00 GMT 2000


This is a partial analysis of f-torture/execute/20000503-1.f

This failure occurs on all platforms, and at all optimisation levels.
It does not fail for:
   gcc-2.95
   snapshots up to and including 19991006
 
I think:
  this shows that the error occurs during RTL generation,
  something weird is being attempted

The bug has been isolated to the subroutine below.

      INTEGER FUNCTION SLASQX( N )
      INTEGER  N, I0, I, K
      I0 = 1
      DO I = 4*I0, 2*( I0+N-1 ), 4
         K = I
      END DO
      SLASQX = K
      RETURN
      END

When called with N=20, the return value is 36, rather than 2*N = 40.

Below is annotated RTL dump after RTL generation (g77 -O0 -c -dr).
This is my first attempt at deciphering RTL.
I think the error occurs in calculating the loop counter,
between instructions 24 and 35.  I don't understand what is
going on there, but it looks complicated and wrong

Variable allocation
  reg 37             = *N
  reg 38             - stack pointer?
  mem( reg 38 -  4 ) = ??? function return value ???
  mem( reg 38 -  8 ) = I0
  mem( reg 38 - 12 ) = I
  mem( reg 38 - 16 ) = K
  mem( reg 38 - 20 ) = loop counter, here after J 

#####################################################################
;; Function slasqx_

(note 2 0 3 NOTE_INSN_DELETED -1347440721)

(note 3 2 6 NOTE_INSN_FUNCTION_BEG -1347440721)

(note 6 3 12 0x14580f60 NOTE_INSN_BLOCK_BEG -1347440721)

(insn 12 6 14 (set (mem/f:SI (plus:SI (reg:SI 38 virtual-stack-vars)
                (const_int -8 [0xfffffff8])) 0)
        (const_int 1 [0x1])) -1 (nil)
    (nil))
#### I0 = -1

(note 14 12 19 0x14580d80 NOTE_INSN_BLOCK_BEG -1347440721)

(insn 19 14 21 (set (reg:SI 42)
        (mem/u/f:SI (reg:SI 37 virtual-incoming-args) 0)) -1 (nil)
    (nil))
### reg_42 = *N

(insn 21 19 22 (set (reg:SI 44)
        (mem:SI (reg:SI 42) 0)) -1 (nil)
    (nil))
### reg_44 = N

(insn 22 21 24 (parallel[ 
            (set (reg:SI 43)
                (plus:SI (mem/f:SI (plus:SI (reg:SI 38 virtual-stack-vars)
                            (const_int -8 [0xfffffff8])) 0)
                    (reg:SI 44)))
            (clobber (reg:CC 17 flags))
        ] ) -1 (nil)
    (expr_list:REG_EQUAL (plus:SI (mem/f:SI (plus:SI (reg:SI 38
virtual-stack-vars)
                    (const_int -8 [0xfffffff8])) 0)
            (mem:SI (reg:SI 42) 0))
        (nil)))
### reg_43 = IO+N

####################### What is happening here ######################

(insn 24 22 26 (parallel[ 
            (set (reg:SI 46)
                (ashiftrt:SI (reg:SI 43)
                    (const_int 31 [0x1f])))
            (clobber (reg:CC 17 flags))
        ] ) -1 (nil)
    (nil))
###  This is where I get confused.  I think that 
###  reg_46 =    0 if reg_43 >= 0
###           ffff if reg_43 <  0
###  If correct, reg_46 = 0 as reg_43 = (IO+N) = 21
 
(insn 26 24 28 (parallel[ 
            (set (reg:SI 47)
                (lshiftrt:SI (reg:SI 46)
                    (const_int 31 [0x1f])))
            (clobber (reg:CC 17 flags))
        ] ) -1 (nil)
    (nil))
### Still uncertain.  Think that
### reg_47 = 0 if reg_43 >= 0
###          1 if reg_43 <  0
### If correct, reg_47 = 0 - This is assumed from now on

(insn 28 26 30 (parallel[ 
            (set (reg:SI 48)
                (plus:SI (reg:SI 43)
                    (reg:SI 47)))
            (clobber (reg:CC 17 flags))
        ] ) -1 (nil)
    (nil))
### reg_48 = I0+N

(insn 30 28 32 (parallel[ 
            (set (reg:SI 45)
                (ashiftrt:SI (reg:SI 48)
                    (const_int 1 [0x1])))
            (clobber (reg:CC 17 flags))
        ] ) -1 (nil)
    (expr_list:REG_EQUAL (div:SI (reg:SI 43)
            (const_int 2 [0x2]))
        (nil)))
### reg_45 = (I0+N)/2   -  Why is this needed?
 
(insn 32 30 33 (set (reg:SI 49)
        (mem/f:SI (plus:SI (reg:SI 38 virtual-stack-vars)
                (const_int -8 [0xfffffff8])) 0)) -1 (nil)
    (nil))
### reg_49 = I0

(insn 33 32 35 (parallel[ 
            (set (reg:SI 50)
                (minus:SI (reg:SI 45)
                    (reg:SI 49)))
            (clobber (reg:CC 17 flags))
        ] ) -1 (nil)
    (nil))
### reg_50 = (I0+N)/2 - I0

(insn 35 33 37 (set (mem/f:SI (plus:SI (reg:SI 38 virtual-stack-vars)
                (const_int -20 [0xffffffec])) 0)
        (reg:SI 50)) -1 (nil)
    (expr_list:REG_EQUAL (minus:SI (reg:SI 45)
            (reg:SI 49))
        (nil)))
### J = (I0+N)/2 - 1
### Now J = (1+20)/2 - 1 = 9.  I think it should be 10.

#################### I think everything below here is OK #####

(insn 37 35 39 (set (reg:SI 52)
        (mem/f:SI (plus:SI (reg:SI 38 virtual-stack-vars)
                (const_int -8 [0xfffffff8])) 0)) -1 (nil)
    (nil))
### reg_52 = I0

(insn 39 37 41 (set (reg:SI 53)
        (reg:SI 52)) -1 (nil)
    (nil))
### reg_53 = I0

(insn 41 39 43 (parallel[ 
            (set (reg:SI 54)
                (ashift:SI (reg:SI 53)
                    (const_int 2 [0x2])))
            (clobber (reg:CC 17 flags))
        ] ) -1 (nil)
    (expr_list:REG_EQUAL (mult:SI (reg:SI 52)
            (const_int 4 [0x4]))
        (nil)))
### reg_54 = 4*I0

(insn 43 41 45 (set (reg:SI 51)
        (reg:SI 54)) -1 (nil)
    (nil))
### reg_51 = 4*I0

(insn 45 43 46 (set (mem/f:SI (plus:SI (reg:SI 38 virtual-stack-vars)
                (const_int -12 [0xfffffff4])) 0)
        (reg:SI 51)) -1 (nil)
    (nil))
### I = 4*I0

(note 46 45 47 NOTE_INSN_LOOP_BEG -1347440721)

(code_label 47 46 49 3 "" "" [0 uses])

(insn 49 47 50 (parallel[ 
            (set (mem/f:SI (plus:SI (reg:SI 38 virtual-stack-vars)
                        (const_int -20 [0xffffffec])) 0)
                (plus:SI (mem/f:SI (plus:SI (reg:SI 38 virtual-stack-vars)
                            (const_int -20 [0xffffffec])) 0)
                    (const_int -1 [0xffffffff])))
            (clobber (reg:CC 17 flags))
        ] ) -1 (nil)
    (nil))
### J = J - 1

(insn 50 49 51 (set (reg:CCNO 17 flags)
        (compare:CCNO (mem/f:SI (plus:SI (reg:SI 38 virtual-stack-vars)
                    (const_int -20 [0xffffffec])) 0)
            (const_int 0 [0x0]))) -1 (nil)
    (nil))
### reg_17 = compare(J,0)

(jump_insn 51 50 52 (set (pc)
        (if_then_else (ge (reg:CCNO 17 flags)
                (const_int 0 [0x0]))
            (label_ref 54)
            (pc))) -1 (nil)
    (nil))
### Guessing a bit here
### if (J >= 0 ) jump to insn 54

(jump_insn 52 51 53 (set (pc)
        (label_ref 71)) -1 (nil)
    (nil))
### otherwise (J<0) jump to insn 71

(barrier 53 52 54)

(code_label 54 53 59 6 "" "" [0 uses])

(insn 59 54 60 (set (reg:SI 55)
        (mem/f:SI (plus:SI (reg:SI 38 virtual-stack-vars)
                (const_int -12 [0xfffffff4])) 0)) -1 (nil)
    (nil))
### reg_55 = I

(insn 60 59 62 (set (mem/f:SI (plus:SI (reg:SI 38 virtual-stack-vars)
                (const_int -16 [0xfffffff0])) 0)
        (reg:SI 55)) -1 (nil)
    (nil))
### K = I

(note 62 60 63 NOTE_INSN_LOOP_CONT -1347440721)

(code_label 63 62 67 5 "" "" [0 uses])

(insn 67 63 68 (parallel[ 
            (set (mem/f:SI (plus:SI (reg:SI 38 virtual-stack-vars)
                        (const_int -12 [0xfffffff4])) 0)
                (plus:SI (mem/f:SI (plus:SI (reg:SI 38 virtual-stack-vars)
                            (const_int -12 [0xfffffff4])) 0)
                    (const_int 4 [0x4])))
            (clobber (reg:CC 17 flags))
        ] ) -1 (nil)
    (nil))
### I = I+4

(jump_insn 68 67 69 (set (pc)
        (label_ref 47)) -1 (nil)
    (nil))
# junl insn 47

(barrier 69 68 70)

(note 70 69 71 NOTE_INSN_LOOP_END -1347440721)

(code_label 71 70 72 4 "" "" [0 uses])

(note 72 71 77 0x14580d80 NOTE_INSN_BLOCK_END -1347440721)

(insn 77 72 78 (set (reg:SI 56)
        (mem/f:SI (plus:SI (reg:SI 38 virtual-stack-vars)
                (const_int -16 [0xfffffff0])) 0)) -1 (nil)
    (nil))
### reg_56 = K

(insn 78 77 83 (set (mem/f:SI (plus:SI (reg:SI 38 virtual-stack-vars)
                (const_int -4 [0xfffffffc])) 0)
        (reg:SI 56)) -1 (nil)
    (nil))
### ??? = K   Guessing this is the return value 

(insn 83 78 85 (set (reg:SI 58)
        (mem/f:SI (plus:SI (reg:SI 38 virtual-stack-vars)
                (const_int -4 [0xfffffffc])) 0)) -1 (nil)
    (nil))
### reg_58 = K
 
(insn 85 83 86 (set (reg/i:SI 0 eax)
        (reg:SI 58)) -1 (nil)
    (nil))
### reg_eax = K

(jump_insn 86 85 87 (set (pc)
        (label_ref 92)) -1 (nil)
    (nil))
### cleaning up???

(barrier 87 86 88)

(note 88 87 89 0x14580f60 NOTE_INSN_BLOCK_END -1347440721)

(note 89 88 91 NOTE_INSN_FUNCTION_END -1347440721)

(insn 91 89 92 (clobber (reg/i:SI 0 eax)) -1 (nil)
    (nil))

(code_label 92 91 93 2 "" "" [0 uses])

(insn 93 92 0 (use (reg/i:SI 0 eax)) -1 (nil)
    (nil))



More information about the Gcc-bugs mailing list