[llvm-commits] [llvm] r110799 - in /llvm/trunk: lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMISelLowering.h test/CodeGen/ARM/select.ll
Bill Wendling
wendling at apple.com
Thu Aug 19 16:18:48 PDT 2010
On Aug 19, 2010, at 3:58 PM, John Tytgat wrote:
> 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
>
Steve Canon pointed out that this is optimal:
_t1:
movw r1, #1123
adr r2, #LCPI0_0
cmp r0, r1
it eq
addeq r2, r2, #4
ldr r0, [r2]
bx lr
Essentially, folding the offset increment into the 'it' block.
-bw
More information about the llvm-commits
mailing list