summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDavid Green <david.green@arm.com>2019-03-17 21:36:15 +0000
committerDavid Green <david.green@arm.com>2019-03-17 21:36:15 +0000
commitbaa94ef03bccbaf7d973c340d873abdaa4e36479 (patch)
treea5d87cbf467639a4009e0f79109fe09812d186d1 /llvm/lib
parent884a18d79253b98aea80f555c2137fad59ccfe80 (diff)
downloadbcm5719-llvm-baa94ef03bccbaf7d973c340d873abdaa4e36479.tar.gz
bcm5719-llvm-baa94ef03bccbaf7d973c340d873abdaa4e36479.zip
[ARM] Check that CPSR does not have other uses
Fix up rL356335 by checking that CPSR is not read between the compare and the branch. llvm-svn: 356349
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/ARM/ARMConstantIslandPass.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp b/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
index 7aefa01f63d..429c2a582bb 100644
--- a/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
+++ b/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
@@ -1912,13 +1912,17 @@ bool ARMConstantIslands::optimizeThumb2Branches() {
if (BrOffset >= DestOffset || (DestOffset - BrOffset) > 126)
continue;
- // Search backwards to the instruction that defines CSPR
+ // Search backwards to the instruction that defines CSPR. This may or not
+ // be a CMP, we check that after this loop. If we find an instruction that
+ // reads cpsr, we need to keep the original cmp.
auto *TRI = STI->getRegisterInfo();
MachineBasicBlock::iterator CmpMI = Br.MI;
while (CmpMI != Br.MI->getParent()->begin()) {
--CmpMI;
if (CmpMI->modifiesRegister(ARM::CPSR, TRI))
break;
+ if (CmpMI->readsRegister(ARM::CPSR, TRI))
+ break;
}
// Check that this inst is a CMP r[0-7], #0 and that the register
OpenPOWER on IntegriCloud