summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/ARM/ARMConstantIslandPass.cpp')
-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