[llvm-branch-commits] [llvm-branch] r101166 - in /llvm/branches/Apple/Morbo: ./ lib/CodeGen/MachineLICM.cpp lib/Transforms/IPO/FunctionAttrs.cpp
Evan Cheng
evan.cheng at apple.com
Tue Apr 13 12:07:46 PDT 2010
Author: evancheng
Date: Tue Apr 13 14:07:46 2010
New Revision: 101166
URL: http://llvm.org/viewvc/llvm-project?rev=101166&view=rev
Log:
Merge: 101154.
Modified:
llvm/branches/Apple/Morbo/ (props changed)
llvm/branches/Apple/Morbo/lib/CodeGen/MachineLICM.cpp
llvm/branches/Apple/Morbo/lib/Transforms/IPO/FunctionAttrs.cpp (props changed)
Propchange: llvm/branches/Apple/Morbo/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Apr 13 14:07:46 2010
@@ -1,2 +1,2 @@
/llvm/branches/Apple/Hermes:96832,96835,96858,96870,96876,96879
-/llvm/trunk:98602,98604,98612,98615-98616,98675,98686,98743-98744,98768,98773,98778,98780,98810,98835,98839,98845,98855,98862,98881,98920,98977,99032-99033,99043,99196,99223,99263,99282-99284,99306,99319-99321,99324,99336,99378,99418,99423,99429,99455,99463,99465,99469,99484,99490,99492-99494,99507,99524,99537,99539-99540,99544,99570,99575,99598,99620,99629-99630,99636,99671,99692,99695,99697,99699,99722,99816,99836,99845-99846,99848,99850,99855,99879,99881-99883,99895,99899,99910,99916,99919,99952-99954,99957,99959,99974-99975,99982,99984-99986,99988,99992-99993,99995,99997-99999,100016,100035,100037-100038,100042,100044,100056,100072,100074,100081-100090,100092,100094-100095,100116,100134,100184,100209,100214-100218,100220-100221,100223-100225,100257,100261,100304,100332,100353,100384,100457,100478,100480,100487,100494,100497,100521,100553,100568,100584,100592,100609-100610,100710,100736,100742,100751,100804,100837,100892,101011,101023,101075,101077,101079,101081
+/llvm/trunk:98602,98604,98612,98615-98616,98675,98686,98743-98744,98768,98773,98778,98780,98810,98835,98839,98845,98855,98862,98881,98920,98977,99032-99033,99043,99196,99223,99263,99282-99284,99306,99319-99321,99324,99336,99378,99418,99423,99429,99455,99463,99465,99469,99484,99490,99492-99494,99507,99524,99537,99539-99540,99544,99570,99575,99598,99620,99629-99630,99636,99671,99692,99695,99697,99699,99722,99816,99836,99845-99846,99848,99850,99855,99879,99881-99883,99895,99899,99910,99916,99919,99952-99954,99957,99959,99974-99975,99982,99984-99986,99988,99992-99993,99995,99997-99999,100016,100035,100037-100038,100042,100044,100056,100072,100074,100081-100090,100092,100094-100095,100116,100134,100184,100209,100214-100218,100220-100221,100223-100225,100257,100261,100304,100332,100353,100384,100457,100478,100480,100487,100494,100497,100521,100553,100568,100584,100592,100609-100610,100710,100736,100742,100751,100804,100837,100892,101011,101023,101075,101077,101079,101081,101085,10
1154
Modified: llvm/branches/Apple/Morbo/lib/CodeGen/MachineLICM.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/CodeGen/MachineLICM.cpp?rev=101166&r1=101165&r2=101166&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/CodeGen/MachineLICM.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/CodeGen/MachineLICM.cpp Tue Apr 13 14:07:46 2010
@@ -101,10 +101,10 @@
/// CandidateInfo - Keep track of information about hoisting candidates.
struct CandidateInfo {
MachineInstr *MI;
- int FI;
unsigned Def;
- CandidateInfo(MachineInstr *mi, int fi, unsigned def)
- : MI(mi), FI(fi), Def(def) {}
+ int FI;
+ CandidateInfo(MachineInstr *mi, unsigned def, int fi)
+ : MI(mi), Def(def), FI(fi) {}
};
/// HoistRegionPostRA - Walk the specified region of the CFG and hoist loop
@@ -127,6 +127,11 @@
void AddToLiveIns(unsigned Reg,
MachineBasicBlock *MBB, MachineBasicBlock *LoopHeader);
+ /// IsLICMCandidate - Returns true if the instruction may be a suitable
+ /// candidate for LICM. e.g. If the instruction is a call, then it's obviously
+ /// not safe to hoist it.
+ bool IsLICMCandidate(MachineInstr &I);
+
/// IsLoopInvariantInst - Returns true if the instruction is loop
/// invariant. I.e., all virtual register operands are defined outside of
/// the loop, physical registers aren't accessed (explicitly or implicitly),
@@ -275,6 +280,7 @@
SmallSet<int, 32> &StoredFIs,
SmallVector<CandidateInfo, 32> &Candidates) {
bool RuledOut = false;
+ bool HasRegFIUse = false;
unsigned Def = 0;
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
const MachineOperand &MO = MI->getOperand(i);
@@ -285,6 +291,7 @@
MFI->isSpillSlotObjectIndex(FI) &&
InstructionStoresToFI(MI, FI))
StoredFIs.insert(FI);
+ HasRegFIUse = true;
continue;
}
@@ -296,8 +303,10 @@
assert(TargetRegisterInfo::isPhysicalRegister(Reg) &&
"Not expecting virtual register!");
- if (!MO.isDef())
+ if (!MO.isDef()) {
+ HasRegFIUse = true;
continue;
+ }
if (MO.isImplicit()) {
++PhysRegDefs[Reg];
@@ -329,13 +338,15 @@
RuledOut = true;
}
- // FIXME: Only consider reloads for now. We should be able to handle
- // remats which does not have register operands.
+ // Only consider reloads for now and remats which do not have register
+ // operands. FIXME: Consider unfold load folding instructions.
if (Def && !RuledOut) {
- int FI;
- if (TII->isLoadFromStackSlot(MI, FI) &&
- MFI->isSpillSlotObjectIndex(FI))
- Candidates.push_back(CandidateInfo(MI, FI, Def));
+ int FI = INT_MIN;
+ // FIXME: Also hoist instructions if all source operands are live in
+ // to the loop.
+ if ((!HasRegFIUse && IsLICMCandidate(*MI)) ||
+ (TII->isLoadFromStackSlot(MI, FI) && MFI->isSpillSlotObjectIndex(FI)))
+ Candidates.push_back(CandidateInfo(MI, Def, FI));
}
}
@@ -389,7 +400,8 @@
// 2. If the candidate is a load from stack slot (always true for now),
// check if the slot is stored anywhere in the loop.
for (unsigned i = 0, e = Candidates.size(); i != e; ++i) {
- if (StoredFIs.count(Candidates[i].FI))
+ if (Candidates[i].FI != INT_MIN &&
+ StoredFIs.count(Candidates[i].FI))
continue;
if (PhysRegDefs[Candidates[i].Def] == 1)
@@ -472,12 +484,10 @@
HoistRegion(Children[I]);
}
-/// IsLoopInvariantInst - Returns true if the instruction is loop
-/// invariant. I.e., all virtual register operands are defined outside of the
-/// loop, physical registers aren't accessed explicitly, and there are no side
-/// effects that aren't captured by the operands or other flags.
-///
-bool MachineLICM::IsLoopInvariantInst(MachineInstr &I) {
+/// IsLICMCandidate - Returns true if the instruction may be a suitable
+/// candidate for LICM. e.g. If the instruction is a call, then it's obviously
+/// not safe to hoist it.
+bool MachineLICM::IsLICMCandidate(MachineInstr &I) {
const TargetInstrDesc &TID = I.getDesc();
// Ignore stuff that we obviously can't hoist.
@@ -495,6 +505,17 @@
// This is a trivial form of alias analysis.
return false;
}
+ return true;
+}
+
+/// IsLoopInvariantInst - Returns true if the instruction is loop
+/// invariant. I.e., all virtual register operands are defined outside of the
+/// loop, physical registers aren't accessed explicitly, and there are no side
+/// effects that aren't captured by the operands or other flags.
+///
+bool MachineLICM::IsLoopInvariantInst(MachineInstr &I) {
+ if (!IsLICMCandidate(I))
+ return false;
// The instruction is loop invariant if all of its operands are.
for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) {
Propchange: llvm/branches/Apple/Morbo/lib/Transforms/IPO/FunctionAttrs.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Apr 13 14:07:46 2010
@@ -1 +1 @@
-/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp:99196,99492,99507,99524,99539-99540,99636,99699,99816,99836,99845-99846,99848,99850,99855,99879,99881-99883,99895,99899,99910,99916,99919,99952-99954,99957,99959,99974-99975,99982,99984-99986,99988,99992-99993,99995,99997-99999,100016,100035,100038,100042,100044,100056,100072,100074,100081-100090,100092,100094-100095,100116,100132-100134,100137,100170,100184,100208-100209,100214-100218,100220-100221,100223-100225,100257,100261,100304,100384,100457,100478,100480,100487,100494,100497,100521,100553,100568,100584,100592,100609-100610,100710,100736,100742,100751,100804,100837,100892,101011,101023,101075,101077,101079,101081
+/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp:99196,99492,99507,99524,99539-99540,99636,99699,99816,99836,99845-99846,99848,99850,99855,99879,99881-99883,99895,99899,99910,99916,99919,99952-99954,99957,99959,99974-99975,99982,99984-99986,99988,99992-99993,99995,99997-99999,100016,100035,100038,100042,100044,100056,100072,100074,100081-100090,100092,100094-100095,100116,100132-100134,100137,100170,100184,100208-100209,100214-100218,100220-100221,100223-100225,100257,100261,100304,100384,100457,100478,100480,100487,100494,100497,100521,100553,100568,100584,100592,100609-100610,100710,100736,100742,100751,100804,100837,100892,101011,101023,101075,101077,101079,101081,101085,101154
More information about the llvm-branch-commits
mailing list