Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Thumb] Resolve FIXME: Use 'mov hi, $src; mov $dst, hi' #81908

Merged
merged 1 commit into from
Apr 5, 2024

Commits on Apr 2, 2024

  1. [Thumb] Resolve FIXME: Use 'mov hi, $src; mov $dst, hi'

    Consider the following:
    
            ldr     r0, [r4]
            ldr     r7, [r0, #4]
            cmp     r7, r3
            bhi     .LBB0_6
            cmp     r0, r2
            push    {r0}
            pop     {r4}
            bne     .LBB0_3
            movs    r0, r6
            pop     {r4, r5, r6, r7}
            pop     {r1}
            bx      r1
    
    Here is a snippet of the generated THUMB1 code of the K&R malloc function that clang currently compiles to.
    
    push    {r0} ends up being popped to pop {r4}.
    
    movs r4, r0 would destroy the flags set by cmp right above.
    
    The compiler has no alternative in this case, except one:
    the only alternative is to transfer through a high register.
    
    However, it seems like LLVM does not consider that this is a valid approach, even though it is a free clobbering a high register.
    
    This patch addresses the FIXME so the compiler can do that when it can in r10 or r11, or r12.
    AtariDreams committed Apr 2, 2024
    Configuration menu
    Copy the full SHA
    675922e View commit details
    Browse the repository at this point in the history