Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 49ee2f2

Browse files
committed
[ARM] Cleanup part of ARMBaseInstrInfo::optimizeCompareInstr (NFCI).
As noted in another review, this loop is confusing. This commit cleans it up somewhat. Differential Revision: https://reviews.llvm.org/D42312 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323136 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 7193f5e commit 49ee2f2

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

lib/Target/ARM/ARMBaseInstrInfo.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2736,35 +2736,31 @@ bool ARMBaseInstrInfo::optimizeCompareInstr(
27362736
}
27372737
I = CmpInstr;
27382738
E = MI;
2739-
} else if (E != B) {
2740-
// Allow the loop below to search E (which was initially MI). Since MI and
2741-
// SubAdd have different tests, even if that instruction could not be MI, it
2742-
// could still potentially be SubAdd.
2743-
--E;
27442739
}
27452740

27462741
// Check that CPSR isn't set between the comparison instruction and the one we
27472742
// want to change. At the same time, search for SubAdd.
27482743
const TargetRegisterInfo *TRI = &getRegisterInfo();
2749-
--I;
2750-
for (; I != E; --I) {
2751-
const MachineInstr &Instr = *I;
2744+
do {
2745+
const MachineInstr &Instr = *--I;
27522746

27532747
// Check whether CmpInstr can be made redundant by the current instruction.
2754-
if (isRedundantFlagInstr(&CmpInstr, SrcReg, SrcReg2, CmpValue, &*I)) {
2748+
if (isRedundantFlagInstr(&CmpInstr, SrcReg, SrcReg2, CmpValue, &Instr)) {
27552749
SubAdd = &*I;
27562750
break;
27572751
}
27582752

2753+
// Allow E (which was initially MI) to be SubAdd but do not search before E.
2754+
if (I == E)
2755+
break;
2756+
27592757
if (Instr.modifiesRegister(ARM::CPSR, TRI) ||
27602758
Instr.readsRegister(ARM::CPSR, TRI))
27612759
// This instruction modifies or uses CPSR after the one we want to
27622760
// change. We can't do this transformation.
27632761
return false;
27642762

2765-
if (I == B)
2766-
break;
2767-
}
2763+
} while (I != B);
27682764

27692765
// Return false if no candidates exist.
27702766
if (!MI && !SubAdd)

0 commit comments

Comments
 (0)