fix opt/2960

David Edelsohn dje@watson.ibm.com
Mon Oct 7 14:50:00 GMT 2002


>>>>> Richard Henderson writes:

Richard> This analysis is incorrect.  insn 38 has been moved up to the 
Richard> beginning of block 1, across the backedge from block 1 to block 2,
Richard> and placed "at the end" of block 2, then scheduled.

Richard> So at it's current position in block 2, we're incrementing R41
Richard> for the _next_ loop iteration.

Richard> So the schedule looks ok to me.  Perhaps it's the doloop optimization
Richard> going wrong...  Try -fno-branch-count-reg.

	Yes, that works.

	With -Os versus -O2, GCC produces code which skips the first
iteration so the doloop performs one less iteration than necessary.

        li 0,5		; prepare value for counter
        li 11,0		; initialize value to be stored
        mtctr 0		; initialize counter
        b L..17		; jump around store and increment to initialize array
L..42:			; location
        stwx 11,31,0	; store value in array
        addi 11,11,1	; increment value
L..17:
        slwi 0,11,2	; calculate next array index
        addi 31,1,56	; calculate array base address (repeatedly)
        bdnz L..42	; loop

The first iteration decrements the loop without storing anything.  With
-O2, the loop is arranged for a direct path to the first iteration:

        addi 31,1,56
        li 0,5
        li 10,0
        mtctr 0
L..57:
        slwi 0,10,2
        stwx 10,31,0
        addi 10,10,1
        bdnz L..57

David



More information about the Gcc-patches mailing list