[llvm] r274290 - CodeGen: Use MachineInstr& in IfConversion, NFC
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 30 16:04:51 PDT 2016
Author: dexonsmith
Date: Thu Jun 30 18:04:51 2016
New Revision: 274290
URL: http://llvm.org/viewvc/llvm-project?rev=274290&view=rev
Log:
CodeGen: Use MachineInstr& in IfConversion, NFC
Switch to a range-based for in IfConverter::PredicateBlock and take
MachineInstr& in MaySpeculate to avoid an implicit conversion from
MachineBasicBlock::iterator to MachineInstr*.
Modified:
llvm/trunk/lib/CodeGen/IfConversion.cpp
Modified: llvm/trunk/lib/CodeGen/IfConversion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IfConversion.cpp?rev=274290&r1=274289&r2=274290&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/IfConversion.cpp (original)
+++ llvm/trunk/lib/CodeGen/IfConversion.cpp Thu Jun 30 18:04:51 2016
@@ -1588,14 +1588,14 @@ bool IfConverter::IfConvertDiamond(BBInf
return true;
}
-static bool MaySpeculate(const MachineInstr *MI,
+static bool MaySpeculate(const MachineInstr &MI,
SmallSet<unsigned, 4> &LaterRedefs) {
bool SawStore = true;
- if (!MI->isSafeToMove(nullptr, SawStore))
+ if (!MI.isSafeToMove(nullptr, SawStore))
return false;
- for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
- const MachineOperand &MO = MI->getOperand(i);
+ for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
+ const MachineOperand &MO = MI.getOperand(i);
if (!MO.isReg())
continue;
unsigned Reg = MO.getReg();
@@ -1616,8 +1616,8 @@ void IfConverter::PredicateBlock(BBInfo
SmallSet<unsigned, 4> *LaterRedefs) {
bool AnyUnpred = false;
bool MaySpec = LaterRedefs != nullptr;
- for (MachineBasicBlock::iterator I = BBI.BB->begin(); I != E; ++I) {
- if (I->isDebugValue() || TII->isPredicated(*I))
+ for (MachineInstr &I : llvm::make_range(BBI.BB->begin(), E)) {
+ if (I.isDebugValue() || TII->isPredicated(I))
continue;
// It may be possible not to predicate an instruction if it's the 'true'
// side of a diamond and the 'false' side may re-define the instruction's
@@ -1629,16 +1629,16 @@ void IfConverter::PredicateBlock(BBInfo
// If any instruction is predicated, then every instruction after it must
// be predicated.
MaySpec = false;
- if (!TII->PredicateInstruction(*I, Cond)) {
+ if (!TII->PredicateInstruction(I, Cond)) {
#ifndef NDEBUG
- dbgs() << "Unable to predicate " << *I << "!\n";
+ dbgs() << "Unable to predicate " << I << "!\n";
#endif
llvm_unreachable(nullptr);
}
// If the predicated instruction now redefines a register as the result of
// if-conversion, add an implicit kill.
- UpdatePredRedefs(*I, Redefs);
+ UpdatePredRedefs(I, Redefs);
}
BBI.Predicate.append(Cond.begin(), Cond.end());
More information about the llvm-commits
mailing list