------- Comment #11 from stevenb dot gcc at gmail dot com  2010-01-11 08:22 
-------
Subject: Re:  redundant memory load

On Mon, Jan 11, 2010 at 7:47 AM, carrot at google dot com
<gcc-bugzi...@gcc.gnu.org> wrote:
>> iterate:
>>         push    {lr}
>>         ldr     r3, [r1]
>> .L6:
>>         str     r3, [r0]
>>         sub     r2, r3, #0
>>         bne     .L5
>>         b       .L3
>> .L4:
>>         ldr     r3, [r3, #8]
>>         b       .L6
>> .L5:
>>         ldr     r1, [r3, #4]
>>         cmp     r1, #0
>>         beq     .L4
>> .L3:
>>         str     r2, [r0, #12]
>>         @ sp needed for prologue
>>         pop     {pc}
>>
>> Carrot, could you please double-check that this is still correct code?
>>
>
> Yes, it is correct.
> There are still 13 instructions, I think it is related to unoptimized basic
> block order.

Yes, I would have expected the block starting with .L4 to be *after*
the block starting with .L5, something like so:

iterate:
        push    {lr}
        ldr     r3, [r1]
.L6:
        str     r3, [r0]
        sub     r2, r3, #0
        beq     .L3
.L5:
        ldr     r1, [r3, #4]
        cmp     r1, #0
        bne     .L3
        ldr     r3, [r3, #8]
        b       .L6
.L3:
        str     r2, [r0, #12]
        @ sp needed for prologue
        pop     {pc}

Does that look correct?  And if so, could you see if there is an open
bug report about this; or otherwise file a new PR and add me to the
CC-list?


-- 


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

Reply via email to