[all-commits] [llvm/llvm-project] c5d000: [Thumb] Resolve FIXME: Use 'mov hi, $src; mov $dst...

AtariDreams via All-commits all-commits at lists.llvm.org
Fri Apr 5 02:18:44 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c5d000b1a84cfee99db157c6819e0a9c518f8ac8
      https://github.com/llvm/llvm-project/commit/c5d000b1a84cfee99db157c6819e0a9c518f8ac8
  Author: AtariDreams <gfunni234 at gmail.com>
  Date:   2024-04-05 (Fri, 05 Apr 2024)

  Changed paths:
    M llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
    M llvm/test/CodeGen/ARM/sadd_sat.ll
    M llvm/test/CodeGen/ARM/select_const.ll
    M llvm/test/CodeGen/ARM/wide-compares.ll
    M llvm/test/CodeGen/Thumb/pr35836.ll
    M llvm/test/CodeGen/Thumb/urem-seteq-illegal-types.ll

  Log Message:
  -----------
  [Thumb] Resolve FIXME: Use 'mov hi, $src; mov $dst, hi' (#81908)

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.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list