ARM: peephole optimization to remove cmp instruction
authorManman Ren <mren@apple.com>
Thu, 10 May 2012 16:48:21 +0000 (16:48 +0000)
committerManman Ren <mren@apple.com>
Thu, 10 May 2012 16:48:21 +0000 (16:48 +0000)
commit8ae4f062e4aefe60732b3fc135769aaedddf082d
tree662271e4a9b9fce2b9fc6841b505ce6c3543e1a7
parent9df72a93ef27a27c6853eed3ed92c9e0b62c9ca6
ARM: peephole optimization to remove cmp instruction

This patch will optimize the following cases:
  sub r1, r3 | sub r1, imm
  cmp r3, r1 or cmp r1, r3 | cmp r1, imm
  bge L1

TO
  subs r1, r3
  bge  L1 or ble L1

If the branch instruction can use flag from "sub", then we can replace
"sub" with "subs" and eliminate the "cmp" instruction.

rdar: 10734411

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156550 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/PeepholeOptimizer.cpp
lib/Target/ARM/ARMBaseInstrInfo.cpp
test/CodeGen/ARM/sub-cmp-peephole.ll [new file with mode: 0644]