blob: cfe50408e6e316ebff326e278f04521de3724f1e [file] [log] [blame]
Evan Chengc6fe3332010-03-02 02:38:24 +00001//===-- MachineCSE.cpp - Machine Common Subexpression Elimination Pass ----===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This pass performs global common subexpression elimination on machine
Evan Chengc5bbba12010-03-02 19:02:27 +000011// instructions using a scoped hash table based value numbering scheme. It
Evan Chengc6fe3332010-03-02 02:38:24 +000012// must be run while the machine function is still in SSA form.
13//
14//===----------------------------------------------------------------------===//
15
16#define DEBUG_TYPE "machine-cse"
17#include "llvm/CodeGen/Passes.h"
18#include "llvm/CodeGen/MachineDominators.h"
19#include "llvm/CodeGen/MachineInstr.h"
Evan Cheng6ba95542010-03-03 02:48:20 +000020#include "llvm/CodeGen/MachineRegisterInfo.h"
Evan Chenga5f32cb2010-03-04 21:18:08 +000021#include "llvm/Analysis/AliasAnalysis.h"
Evan Cheng6ba95542010-03-03 02:48:20 +000022#include "llvm/Target/TargetInstrInfo.h"
Evan Cheng31156982010-04-21 00:21:07 +000023#include "llvm/ADT/DenseMap.h"
Evan Chengc6fe3332010-03-02 02:38:24 +000024#include "llvm/ADT/ScopedHashTable.h"
25#include "llvm/ADT/Statistic.h"
26#include "llvm/Support/Debug.h"
27
28using namespace llvm;
29
Evan Cheng16b48b82010-03-03 21:20:05 +000030STATISTIC(NumCoalesces, "Number of copies coalesced");
31STATISTIC(NumCSEs, "Number of common subexpression eliminated");
32
Evan Chengc6fe3332010-03-02 02:38:24 +000033namespace {
34 class MachineCSE : public MachineFunctionPass {
Evan Cheng6ba95542010-03-03 02:48:20 +000035 const TargetInstrInfo *TII;
Evan Chengb3958e82010-03-04 01:33:55 +000036 const TargetRegisterInfo *TRI;
Evan Chenga5f32cb2010-03-04 21:18:08 +000037 AliasAnalysis *AA;
Evan Cheng31f94c72010-03-09 03:21:12 +000038 MachineDominatorTree *DT;
39 MachineRegisterInfo *MRI;
Evan Chengc6fe3332010-03-02 02:38:24 +000040 public:
41 static char ID; // Pass identification
Evan Cheng6ba95542010-03-03 02:48:20 +000042 MachineCSE() : MachineFunctionPass(&ID), CurrVN(0) {}
Evan Chengc6fe3332010-03-02 02:38:24 +000043
44 virtual bool runOnMachineFunction(MachineFunction &MF);
45
46 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
47 AU.setPreservesCFG();
48 MachineFunctionPass::getAnalysisUsage(AU);
Evan Chenga5f32cb2010-03-04 21:18:08 +000049 AU.addRequired<AliasAnalysis>();
Evan Chengc6fe3332010-03-02 02:38:24 +000050 AU.addRequired<MachineDominatorTree>();
51 AU.addPreserved<MachineDominatorTree>();
52 }
53
54 private:
Evan Cheng31156982010-04-21 00:21:07 +000055 typedef ScopedHashTableScope<MachineInstr*, unsigned,
56 MachineInstrExpressionTrait> ScopeType;
57 DenseMap<MachineBasicBlock*, ScopeType*> ScopeMap;
Evan Cheng05bdcbb2010-03-03 23:27:36 +000058 ScopedHashTable<MachineInstr*, unsigned, MachineInstrExpressionTrait> VNT;
Evan Cheng16b48b82010-03-03 21:20:05 +000059 SmallVector<MachineInstr*, 64> Exps;
Evan Cheng31156982010-04-21 00:21:07 +000060 unsigned CurrVN;
Evan Cheng16b48b82010-03-03 21:20:05 +000061
Evan Chenga5f32cb2010-03-04 21:18:08 +000062 bool PerformTrivialCoalescing(MachineInstr *MI, MachineBasicBlock *MBB);
Evan Chengb3958e82010-03-04 01:33:55 +000063 bool isPhysDefTriviallyDead(unsigned Reg,
64 MachineBasicBlock::const_iterator I,
65 MachineBasicBlock::const_iterator E);
Evan Chenga5f32cb2010-03-04 21:18:08 +000066 bool hasLivePhysRegDefUse(MachineInstr *MI, MachineBasicBlock *MBB);
67 bool isCSECandidate(MachineInstr *MI);
Evan Cheng2938a002010-03-10 02:12:03 +000068 bool isProfitableToCSE(unsigned CSReg, unsigned Reg,
69 MachineInstr *CSMI, MachineInstr *MI);
Evan Cheng31156982010-04-21 00:21:07 +000070 void EnterScope(MachineBasicBlock *MBB);
71 void ExitScope(MachineBasicBlock *MBB);
72 bool ProcessBlock(MachineBasicBlock *MBB);
73 void ExitScopeIfDone(MachineDomTreeNode *Node,
74 DenseMap<MachineDomTreeNode*, unsigned> &OpenChildren,
75 DenseMap<MachineDomTreeNode*, MachineDomTreeNode*> &ParentMap);
76 bool PerformCSE(MachineDomTreeNode *Node);
Evan Chengc6fe3332010-03-02 02:38:24 +000077 };
78} // end anonymous namespace
79
80char MachineCSE::ID = 0;
81static RegisterPass<MachineCSE>
82X("machine-cse", "Machine Common Subexpression Elimination");
83
84FunctionPass *llvm::createMachineCSEPass() { return new MachineCSE(); }
85
Evan Cheng6ba95542010-03-03 02:48:20 +000086bool MachineCSE::PerformTrivialCoalescing(MachineInstr *MI,
87 MachineBasicBlock *MBB) {
88 bool Changed = false;
89 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
90 MachineOperand &MO = MI->getOperand(i);
Evan Cheng16b48b82010-03-03 21:20:05 +000091 if (!MO.isReg() || !MO.isUse())
92 continue;
93 unsigned Reg = MO.getReg();
94 if (!Reg || TargetRegisterInfo::isPhysicalRegister(Reg))
95 continue;
96 if (!MRI->hasOneUse(Reg))
97 // Only coalesce single use copies. This ensure the copy will be
98 // deleted.
99 continue;
100 MachineInstr *DefMI = MRI->getVRegDef(Reg);
101 if (DefMI->getParent() != MBB)
102 continue;
103 unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx;
104 if (TII->isMoveInstr(*DefMI, SrcReg, DstReg, SrcSubIdx, DstSubIdx) &&
105 TargetRegisterInfo::isVirtualRegister(SrcReg) &&
106 !SrcSubIdx && !DstSubIdx) {
Evan Chengbfc99992010-03-09 06:38:17 +0000107 const TargetRegisterClass *SRC = MRI->getRegClass(SrcReg);
108 const TargetRegisterClass *RC = MRI->getRegClass(Reg);
109 const TargetRegisterClass *NewRC = getCommonSubClass(RC, SRC);
110 if (!NewRC)
111 continue;
112 DEBUG(dbgs() << "Coalescing: " << *DefMI);
113 DEBUG(dbgs() << "*** to: " << *MI);
114 MO.setReg(SrcReg);
Dan Gohman49b45892010-05-13 19:24:00 +0000115 MRI->clearKillFlags(SrcReg);
Evan Chengbfc99992010-03-09 06:38:17 +0000116 if (NewRC != SRC)
117 MRI->setRegClass(SrcReg, NewRC);
118 DefMI->eraseFromParent();
119 ++NumCoalesces;
120 Changed = true;
Evan Cheng6ba95542010-03-03 02:48:20 +0000121 }
122 }
123
124 return Changed;
125}
126
Evan Chengb3958e82010-03-04 01:33:55 +0000127bool MachineCSE::isPhysDefTriviallyDead(unsigned Reg,
128 MachineBasicBlock::const_iterator I,
129 MachineBasicBlock::const_iterator E) {
130 unsigned LookAheadLeft = 5;
Evan Cheng112e5e72010-03-23 20:33:48 +0000131 while (LookAheadLeft) {
Evan Cheng22504252010-03-24 01:50:28 +0000132 // Skip over dbg_value's.
133 while (I != E && I->isDebugValue())
134 ++I;
135
Evan Chengb3958e82010-03-04 01:33:55 +0000136 if (I == E)
137 // Reached end of block, register is obviously dead.
138 return true;
139
Evan Chengb3958e82010-03-04 01:33:55 +0000140 bool SeenDef = false;
141 for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) {
142 const MachineOperand &MO = I->getOperand(i);
143 if (!MO.isReg() || !MO.getReg())
144 continue;
145 if (!TRI->regsOverlap(MO.getReg(), Reg))
146 continue;
147 if (MO.isUse())
148 return false;
149 SeenDef = true;
150 }
151 if (SeenDef)
152 // See a def of Reg (or an alias) before encountering any use, it's
153 // trivially dead.
154 return true;
Evan Cheng112e5e72010-03-23 20:33:48 +0000155
156 --LookAheadLeft;
Evan Chengb3958e82010-03-04 01:33:55 +0000157 ++I;
158 }
159 return false;
160}
161
Evan Cheng2938a002010-03-10 02:12:03 +0000162/// hasLivePhysRegDefUse - Return true if the specified instruction read / write
163/// physical registers (except for dead defs of physical registers).
Evan Chengb3958e82010-03-04 01:33:55 +0000164bool MachineCSE::hasLivePhysRegDefUse(MachineInstr *MI, MachineBasicBlock *MBB){
165 unsigned PhysDef = 0;
Evan Cheng6ba95542010-03-03 02:48:20 +0000166 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
167 MachineOperand &MO = MI->getOperand(i);
168 if (!MO.isReg())
169 continue;
170 unsigned Reg = MO.getReg();
171 if (!Reg)
172 continue;
Evan Chengb3958e82010-03-04 01:33:55 +0000173 if (TargetRegisterInfo::isPhysicalRegister(Reg)) {
174 if (MO.isUse())
175 // Can't touch anything to read a physical register.
176 return true;
177 if (MO.isDead())
178 // If the def is dead, it's ok.
179 continue;
180 // Ok, this is a physical register def that's not marked "dead". That's
181 // common since this pass is run before livevariables. We can scan
182 // forward a few instructions and check if it is obviously dead.
183 if (PhysDef)
184 // Multiple physical register defs. These are rare, forget about it.
185 return true;
186 PhysDef = Reg;
187 }
188 }
189
190 if (PhysDef) {
191 MachineBasicBlock::iterator I = MI; I = llvm::next(I);
192 if (!isPhysDefTriviallyDead(PhysDef, I, MBB->end()))
Evan Cheng6ba95542010-03-03 02:48:20 +0000193 return true;
Evan Chengc6fe3332010-03-02 02:38:24 +0000194 }
195 return false;
196}
197
Evan Cheng2938a002010-03-10 02:12:03 +0000198static bool isCopy(const MachineInstr *MI, const TargetInstrInfo *TII) {
199 unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx;
200 return TII->isMoveInstr(*MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx) ||
201 MI->isExtractSubreg() || MI->isInsertSubreg() || MI->isSubregToReg();
202}
203
Evan Chenga5f32cb2010-03-04 21:18:08 +0000204bool MachineCSE::isCSECandidate(MachineInstr *MI) {
Evan Cheng51960182010-03-08 23:49:12 +0000205 if (MI->isLabel() || MI->isPHI() || MI->isImplicitDef() ||
Dale Johannesene68ea062010-03-11 02:10:24 +0000206 MI->isKill() || MI->isInlineAsm() || MI->isDebugValue())
Evan Cheng51960182010-03-08 23:49:12 +0000207 return false;
208
Evan Cheng2938a002010-03-10 02:12:03 +0000209 // Ignore copies.
210 if (isCopy(MI, TII))
Evan Chenga5f32cb2010-03-04 21:18:08 +0000211 return false;
212
213 // Ignore stuff that we obviously can't move.
214 const TargetInstrDesc &TID = MI->getDesc();
215 if (TID.mayStore() || TID.isCall() || TID.isTerminator() ||
216 TID.hasUnmodeledSideEffects())
217 return false;
218
219 if (TID.mayLoad()) {
220 // Okay, this instruction does a load. As a refinement, we allow the target
221 // to decide whether the loaded value is actually a constant. If so, we can
222 // actually use it as a load.
223 if (!MI->isInvariantLoad(AA))
224 // FIXME: we should be able to hoist loads with no other side effects if
225 // there are no other instructions which can change memory in this loop.
226 // This is a trivial form of alias analysis.
227 return false;
228 }
229 return true;
230}
231
Evan Cheng31f94c72010-03-09 03:21:12 +0000232/// isProfitableToCSE - Return true if it's profitable to eliminate MI with a
233/// common expression that defines Reg.
Evan Cheng2938a002010-03-10 02:12:03 +0000234bool MachineCSE::isProfitableToCSE(unsigned CSReg, unsigned Reg,
235 MachineInstr *CSMI, MachineInstr *MI) {
236 // FIXME: Heuristics that works around the lack the live range splitting.
237
238 // Heuristics #1: Don't cse "cheap" computating if the def is not local or in an
239 // immediate predecessor. We don't want to increase register pressure and end up
240 // causing other computation to be spilled.
241 if (MI->getDesc().isAsCheapAsAMove()) {
242 MachineBasicBlock *CSBB = CSMI->getParent();
243 MachineBasicBlock *BB = MI->getParent();
244 if (CSBB != BB &&
245 find(CSBB->succ_begin(), CSBB->succ_end(), BB) == CSBB->succ_end())
246 return false;
247 }
248
249 // Heuristics #2: If the expression doesn't not use a vr and the only use
250 // of the redundant computation are copies, do not cse.
251 bool HasVRegUse = false;
252 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
253 const MachineOperand &MO = MI->getOperand(i);
254 if (MO.isReg() && MO.isUse() && MO.getReg() &&
255 TargetRegisterInfo::isVirtualRegister(MO.getReg())) {
256 HasVRegUse = true;
257 break;
258 }
259 }
260 if (!HasVRegUse) {
261 bool HasNonCopyUse = false;
262 for (MachineRegisterInfo::use_nodbg_iterator I = MRI->use_nodbg_begin(Reg),
263 E = MRI->use_nodbg_end(); I != E; ++I) {
264 MachineInstr *Use = &*I;
265 // Ignore copies.
266 if (!isCopy(Use, TII)) {
267 HasNonCopyUse = true;
268 break;
269 }
270 }
271 if (!HasNonCopyUse)
272 return false;
273 }
274
275 // Heuristics #3: If the common subexpression is used by PHIs, do not reuse
276 // it unless the defined value is already used in the BB of the new use.
Evan Cheng31f94c72010-03-09 03:21:12 +0000277 bool HasPHI = false;
278 SmallPtrSet<MachineBasicBlock*, 4> CSBBs;
Evan Cheng2938a002010-03-10 02:12:03 +0000279 for (MachineRegisterInfo::use_nodbg_iterator I = MRI->use_nodbg_begin(CSReg),
Evan Cheng31f94c72010-03-09 03:21:12 +0000280 E = MRI->use_nodbg_end(); I != E; ++I) {
281 MachineInstr *Use = &*I;
282 HasPHI |= Use->isPHI();
283 CSBBs.insert(Use->getParent());
284 }
285
286 if (!HasPHI)
287 return true;
288 return CSBBs.count(MI->getParent());
289}
290
Evan Cheng31156982010-04-21 00:21:07 +0000291void MachineCSE::EnterScope(MachineBasicBlock *MBB) {
292 DEBUG(dbgs() << "Entering: " << MBB->getName() << '\n');
293 ScopeType *Scope = new ScopeType(VNT);
294 ScopeMap[MBB] = Scope;
295}
296
297void MachineCSE::ExitScope(MachineBasicBlock *MBB) {
298 DEBUG(dbgs() << "Exiting: " << MBB->getName() << '\n');
299 DenseMap<MachineBasicBlock*, ScopeType*>::iterator SI = ScopeMap.find(MBB);
300 assert(SI != ScopeMap.end());
301 ScopeMap.erase(SI);
302 delete SI->second;
303}
304
305bool MachineCSE::ProcessBlock(MachineBasicBlock *MBB) {
Evan Cheng6ba95542010-03-03 02:48:20 +0000306 bool Changed = false;
307
Evan Cheng31f94c72010-03-09 03:21:12 +0000308 SmallVector<std::pair<unsigned, unsigned>, 8> CSEPairs;
Evan Cheng16b48b82010-03-03 21:20:05 +0000309 for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end(); I != E; ) {
Evan Cheng6ba95542010-03-03 02:48:20 +0000310 MachineInstr *MI = &*I;
Evan Cheng16b48b82010-03-03 21:20:05 +0000311 ++I;
Evan Chenga5f32cb2010-03-04 21:18:08 +0000312
313 if (!isCSECandidate(MI))
Evan Cheng6ba95542010-03-03 02:48:20 +0000314 continue;
Evan Cheng6ba95542010-03-03 02:48:20 +0000315
316 bool FoundCSE = VNT.count(MI);
317 if (!FoundCSE) {
318 // Look for trivial copy coalescing opportunities.
Evan Chengdb8771a2010-04-02 02:21:24 +0000319 if (PerformTrivialCoalescing(MI, MBB)) {
320 // After coalescing MI itself may become a copy.
321 if (isCopy(MI, TII))
322 continue;
Evan Cheng6ba95542010-03-03 02:48:20 +0000323 FoundCSE = VNT.count(MI);
Evan Chengdb8771a2010-04-02 02:21:24 +0000324 }
Evan Cheng6ba95542010-03-03 02:48:20 +0000325 }
Evan Chengb3958e82010-03-04 01:33:55 +0000326 // FIXME: commute commutable instructions?
Evan Cheng6ba95542010-03-03 02:48:20 +0000327
Evan Cheng67bda722010-03-03 23:59:08 +0000328 // If the instruction defines a physical register and the value *may* be
329 // used, then it's not safe to replace it with a common subexpression.
Evan Chengb3958e82010-03-04 01:33:55 +0000330 if (FoundCSE && hasLivePhysRegDefUse(MI, MBB))
Evan Cheng67bda722010-03-03 23:59:08 +0000331 FoundCSE = false;
332
Evan Cheng16b48b82010-03-03 21:20:05 +0000333 if (!FoundCSE) {
334 VNT.insert(MI, CurrVN++);
335 Exps.push_back(MI);
336 continue;
337 }
338
339 // Found a common subexpression, eliminate it.
340 unsigned CSVN = VNT.lookup(MI);
341 MachineInstr *CSMI = Exps[CSVN];
342 DEBUG(dbgs() << "Examining: " << *MI);
343 DEBUG(dbgs() << "*** Found a common subexpression: " << *CSMI);
Evan Cheng31f94c72010-03-09 03:21:12 +0000344
345 // Check if it's profitable to perform this CSE.
346 bool DoCSE = true;
Evan Cheng16b48b82010-03-03 21:20:05 +0000347 unsigned NumDefs = MI->getDesc().getNumDefs();
348 for (unsigned i = 0, e = MI->getNumOperands(); NumDefs && i != e; ++i) {
349 MachineOperand &MO = MI->getOperand(i);
350 if (!MO.isReg() || !MO.isDef())
351 continue;
352 unsigned OldReg = MO.getReg();
353 unsigned NewReg = CSMI->getOperand(i).getReg();
Evan Cheng6cc1aea2010-03-06 01:14:19 +0000354 if (OldReg == NewReg)
355 continue;
356 assert(TargetRegisterInfo::isVirtualRegister(OldReg) &&
Evan Cheng16b48b82010-03-03 21:20:05 +0000357 TargetRegisterInfo::isVirtualRegister(NewReg) &&
358 "Do not CSE physical register defs!");
Evan Cheng2938a002010-03-10 02:12:03 +0000359 if (!isProfitableToCSE(NewReg, OldReg, CSMI, MI)) {
Evan Cheng31f94c72010-03-09 03:21:12 +0000360 DoCSE = false;
361 break;
362 }
363 CSEPairs.push_back(std::make_pair(OldReg, NewReg));
Evan Cheng16b48b82010-03-03 21:20:05 +0000364 --NumDefs;
365 }
Evan Cheng31f94c72010-03-09 03:21:12 +0000366
367 // Actually perform the elimination.
368 if (DoCSE) {
Dan Gohman49b45892010-05-13 19:24:00 +0000369 for (unsigned i = 0, e = CSEPairs.size(); i != e; ++i) {
Evan Cheng31f94c72010-03-09 03:21:12 +0000370 MRI->replaceRegWith(CSEPairs[i].first, CSEPairs[i].second);
Dan Gohman49b45892010-05-13 19:24:00 +0000371 MRI->clearKillFlags(CSEPairs[i].second);
372 }
Evan Cheng31f94c72010-03-09 03:21:12 +0000373 MI->eraseFromParent();
374 ++NumCSEs;
375 } else {
376 DEBUG(dbgs() << "*** Not profitable, avoid CSE!\n");
377 VNT.insert(MI, CurrVN++);
378 Exps.push_back(MI);
379 }
380 CSEPairs.clear();
Evan Cheng6ba95542010-03-03 02:48:20 +0000381 }
382
Evan Cheng31156982010-04-21 00:21:07 +0000383 return Changed;
384}
385
386/// ExitScopeIfDone - Destroy scope for the MBB that corresponds to the given
387/// dominator tree node if its a leaf or all of its children are done. Walk
388/// up the dominator tree to destroy ancestors which are now done.
389void
390MachineCSE::ExitScopeIfDone(MachineDomTreeNode *Node,
391 DenseMap<MachineDomTreeNode*, unsigned> &OpenChildren,
392 DenseMap<MachineDomTreeNode*, MachineDomTreeNode*> &ParentMap) {
393 if (OpenChildren[Node])
394 return;
395
396 // Pop scope.
397 ExitScope(Node->getBlock());
398
399 // Now traverse upwards to pop ancestors whose offsprings are all done.
400 while (MachineDomTreeNode *Parent = ParentMap[Node]) {
401 unsigned Left = --OpenChildren[Parent];
402 if (Left != 0)
403 break;
404 ExitScope(Parent->getBlock());
405 Node = Parent;
406 }
407}
408
409bool MachineCSE::PerformCSE(MachineDomTreeNode *Node) {
410 SmallVector<MachineDomTreeNode*, 32> Scopes;
411 SmallVector<MachineDomTreeNode*, 8> WorkList;
412 DenseMap<MachineDomTreeNode*, MachineDomTreeNode*> ParentMap;
413 DenseMap<MachineDomTreeNode*, unsigned> OpenChildren;
414
415 // Perform a DFS walk to determine the order of visit.
416 WorkList.push_back(Node);
417 do {
418 Node = WorkList.pop_back_val();
419 Scopes.push_back(Node);
420 const std::vector<MachineDomTreeNode*> &Children = Node->getChildren();
421 unsigned NumChildren = Children.size();
422 OpenChildren[Node] = NumChildren;
423 for (unsigned i = 0; i != NumChildren; ++i) {
424 MachineDomTreeNode *Child = Children[i];
425 ParentMap[Child] = Node;
426 WorkList.push_back(Child);
427 }
428 } while (!WorkList.empty());
429
430 // Now perform CSE.
431 bool Changed = false;
432 for (unsigned i = 0, e = Scopes.size(); i != e; ++i) {
433 MachineDomTreeNode *Node = Scopes[i];
434 MachineBasicBlock *MBB = Node->getBlock();
435 EnterScope(MBB);
436 Changed |= ProcessBlock(MBB);
437 // If it's a leaf node, it's done. Traverse upwards to pop ancestors.
438 ExitScopeIfDone(Node, OpenChildren, ParentMap);
439 }
Evan Cheng6ba95542010-03-03 02:48:20 +0000440
441 return Changed;
442}
443
Evan Chengc6fe3332010-03-02 02:38:24 +0000444bool MachineCSE::runOnMachineFunction(MachineFunction &MF) {
Evan Cheng6ba95542010-03-03 02:48:20 +0000445 TII = MF.getTarget().getInstrInfo();
Evan Chengb3958e82010-03-04 01:33:55 +0000446 TRI = MF.getTarget().getRegisterInfo();
Evan Cheng6ba95542010-03-03 02:48:20 +0000447 MRI = &MF.getRegInfo();
Evan Chenga5f32cb2010-03-04 21:18:08 +0000448 AA = &getAnalysis<AliasAnalysis>();
Evan Cheng31f94c72010-03-09 03:21:12 +0000449 DT = &getAnalysis<MachineDominatorTree>();
Evan Cheng31156982010-04-21 00:21:07 +0000450 return PerformCSE(DT->getRootNode());
Evan Chengc6fe3332010-03-02 02:38:24 +0000451}