https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65371

--- Comment #4 from Stuart <gcc-bugzilla at enginuities dot com> ---
The assembly generated from Comment #1 looks good.

However, the assembly generated from Comment #3 hasn't improved, it still
contains the unnecessary mov instruction on line 2 (mov r2, r3).

The first instruction movs the address in to r3 and the second movs r3 in to
r2. The instruction at label .L2 loads data in to r3 from the address in r2,
overwriting r3 and making the instruction on line 2 unnecessary...

I would have expected to see:

func:
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        @ link register save eliminated.
        mov     r2, #1073741824
        ldr     r1, [r2]
.L2:
        ldr     r3, [r2]
        subs    r3, r3, r1
        uxth    r3, r3
        cmp     r3, r0
        bcc     .L2
        bx      lr

Reply via email to