[PATCH] D83745: [ARM] Optimize immediate selection

Ben Shi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 15 08:01:03 PDT 2020


benshi001 added a comment.

for C code

  unsigned int f0(unsigned int a)
  {
          return a-0x2323;
  }
  unsigned int f1(unsigned int a) 
  {
          return a+0x2323;
  }

GCC generates

  f0:
        sub     r0, r0, #8960
        sub     r0, r0, #35
        bx      lr
  f1:
        add     r0, r0, #8960
        add     r0, r0, #35
        bx      lr

but llvm generates

  f0:
        ldr     r1, .LCPI0_0
        add     r0, r0, r1
        bx      lr
  .LCPI0_0:
        .long   4294958301                      @ 0xffffdcdd
  f1:
        add     r0, r0, #35
        add     r0, r0, #8960
        bx      lr

And my patch will make llvm follows GCC's behavior.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83745/new/

https://reviews.llvm.org/D83745





More information about the llvm-commits mailing list