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

--- Comment #12 from Honggyu Kim <hong.gyu.kim at lge dot com> ---
(In reply to ktkachov from comment #11)
> Thinking about it again, there's no reason not to do sibcalls, it's just the
> code gets confused on how to shuffle the arguments around. Will investigate
> deeper

Yes, right. There's no reason not to do sibcall in this case.

>From the original assembly output as below:
foo:
        @ args = 16, pretend = 8, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        sub     sp, sp, #8
        mov     r0, r1
        str     lr, [sp, #-4]!
        add     ip, sp, #8
        ldr     lr, [sp, #16]
        mov     r1, r2
        str     r3, [sp, #8]
(a)     str     lr, [sp, #12]
        ldr     lr, [sp], #4
(b)     ldmia   ip, {r2, r3}
        add     sp, sp, #8
        b       bar

We can place instruction (b) before (a).
In that case, it works fine and sibcall optimization is also done.

Reply via email to