OSDN Git Service

[ARM] Ensure we update the correct flags in the peephole optimiser
authorDavid Green <david.green@arm.com>
Thu, 14 Feb 2019 11:09:24 +0000 (11:09 +0000)
committerDavid Green <david.green@arm.com>
Thu, 14 Feb 2019 11:09:24 +0000 (11:09 +0000)
commit0c8bcbe336b0cd3d74f29260ee5b7157f76ccc5f
tree0724aaddb3a4caa431b9b9c549426913b15d279f
parent8bfdad6a76d34b0fd103888b20a5f1d184fc01ed
[ARM] Ensure we update the correct flags in the peephole optimiser

The Arm peephole optimiser code keeps track of both an MI and a SubAdd that can
be used to optimise away a CMP. In the rare case that both are found and not
ruled-out as valid, we could end up setting the flags on the wrong one.

Instead make sure we are using SubAdd if it exists, as it will be closer to the
CMP.

The testcase here is a little theoretical, with a dead def of cpsr. It should
hopefully show the point.

Differential Revision: https://reviews.llvm.org/D58176

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354018 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/ARM/ARMBaseInstrInfo.cpp
test/CodeGen/Thumb2/peephole-addsub.mir [new file with mode: 0644]