The implementation here is a bit nasty, but the basic idea is that Thumb has more 16-bit encodings available for ADD than it does for ORR. Combine that with LLVM's (slightly perverse) desire to convert adds to ors as the canonical form and we end up with unnecessary bloat on Thumb targets.
So this patch tries to undo that canonicalization where possible. The implementation is not pretty, but I'm not sure there's a better way.
T1Pat?
Are you intentionally avoiding transforming x|256?