I'd replace the first loop by this (untested, no ARM at hand :-)
cmp r1,r3,lsr #16
movls r2,r1,lsl #16
movhi r2,r1
cmp r2,r3,lsr #8
movls r2,r2,lsl #8
cmp r2,r3,lsr #4
movls r2,r2,lsl #4
cmp r2,r3,lsr #2
movls r2,r2,lsl #2
cmp r2,r3,lsr #1
movls r2,r2,lsl #1
Which does omit the...