[llvm-commits] [llvm] r110799 - in /llvm/trunk: lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMISelLowering.h test/CodeGen/ARM/select.ll

John Tytgat john at bass-software.com
Thu Aug 19 15:58:25 PDT 2010


In message <20100811084316.8A1092A6C12C at llvm.org> you wrote:

> Author: void
> Date: Wed Aug 11 03:43:16 2010
> New Revision: 110799
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=110799&view=rev
> Log:
> Consider this code snippet:
> 
> float t1(int argc) {
>   return (argc == 1123) ? 1.234f : 2.38213f;
> }
> [...]
> 
> Now we generate this, which looks optimal to me:
> 
> _t1:
>   movw   r1, #1123
>   movs   r2, #0
>   cmp    r0, r1
>   adr    r0, #LCPI0_0
>   it     eq
>   moveq  r2, #4
>   ldr    r0, [r0, r2]
>   bx     lr
>   .align  2
> LCPI0_0:
>   .long   1075344593  @ float 2.382130e+00
>   .long   1067316150  @ float 1.234000e+00

I don't know enough about Thumb to be sure (much more familiar with ARM)
but can't this be made more compact/faster using SUB instead of CMP
eliminating the MOV Rx, #0 ?

_t1:
  movw   r1, #1123
  subs   r2, r0, r1
  adr    r0, #LCPI0_0
  it     ne
  movne  r2, #4
  ldr    r0, [r0, r2]
  bx     lr
  .align  2
LCPI0_0:
  .long   1067316150  @ float 1.234000e+00
  .long   1075344593  @ float 2.382130e+00

John.
-- 
John Tytgat
John at bass-software.com



More information about the llvm-commits mailing list