Reapply "[ARM] Combine CMOV into BFI where possible"
authorJames Molloy <james.molloy@arm.com>
Tue, 10 Nov 2015 14:22:05 +0000 (14:22 +0000)
committerJames Molloy <james.molloy@arm.com>
Tue, 10 Nov 2015 14:22:05 +0000 (14:22 +0000)
commit20538780aed942110e6b9b775f78a0748ec9f210
treecd6565f57b645584a3d91f5c0942ade7756e174f
parenta277dc299ed5f07fafc138f91891d94904287bad
Reapply "[ARM] Combine CMOV into BFI where possible"

Added fixes for stage2 failures: CMOV is not commutable; commuting the operands results in the condition being flipped! d'oh!

Original commit message:

If we have a CMOV, OR and AND combination such as:
  if (x & CN)
      y |= CM;

And:
  * CN is a single bit;
    * All bits covered by CM are known zero in y;

Then we can convert this to a sequence of BFI instructions. This will always be a win if CM is a single bit, will always be no worse than the TST & OR sequence if CM is two bits, and for thumb will be no worse if CM is three bits (due to the extra IT instruction).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252606 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/ARM/ARMISelLowering.cpp
lib/Target/ARM/ARMISelLowering.h
test/CodeGen/ARM/bfi.ll