Created attachment 9515
bit test example
This is a missing optimization for Thumb2 code.
A bit test on a dead variable is now done with a "tst.w reg,#bit", with
conditions EQ,NE. It could be done with a "lsls reg,#shf" to shift the bit
into the sign bit, with conditions PL,MI.
The test program generates (on the trunk):
bittest:
mov r1, r0
movs r0, #0
tst.w r1, #128
it eq
moveq r0, #42
bx lr
It could generate, 2 bytes smaller:
bittest:
mov r1, r0
movs r0, #0
lsls r1, #24
it pl
movpl r0, #42
bx lr
Even better would be, 4 bytes smaller:
bittest:
lsls r0, #24
ite pl
movpl r0, #42
movmi r0, #0
bx lr
bittest.ll
(410 bytes, application/octet-stream)