Optimize a couple of common patterns involving conditional moves where the false
authorEvan Cheng <evan.cheng@apple.com>
Thu, 23 Feb 2012 01:19:06 +0000 (01:19 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 23 Feb 2012 01:19:06 +0000 (01:19 +0000)
commitc892aeb26601cc5109490d30c7e170cb07f84428
treeca73ce26498fc637a12d4d57cdcb3632b4334793
parentbbad2f1040fea671b4413f53b3fd816cb7bd2443
Optimize a couple of common patterns involving conditional moves where the false
value is zero. Instead of a cmov + op, issue an conditional op instead. e.g.
    cmp   r9, r4
    mov   r4, #0
    moveq r4, #1
    orr   lr, lr, r4

should be:
    cmp   r9, r4
    orreq lr, lr, #1

That is, optimize (or x, (cmov 0, y, cond)) to (or.cond x, y). Similarly extend
this to xor as well as (and x, (cmov -1, y, cond)) => (and.cond x, y).

It's possible to extend this to ADD and SUB but I don't think they are common.

rdar://8659097

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151224 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/ARM/ARMISelDAGToDAG.cpp
lib/Target/ARM/ARMISelLowering.cpp
lib/Target/ARM/ARMISelLowering.h
lib/Target/ARM/ARMInstrInfo.td
lib/Target/ARM/ARMInstrThumb2.td
test/CodeGen/ARM/select_xform.ll