blob: dd32977f90b6c6f6a8ec9b8ec38664b4a8097339 [file] [log] [blame]
Bill Wendling0f940c92007-12-07 21:42:31 +00001//===-- MachineLICM.cpp - Machine Loop Invariant Code Motion Pass ---------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Bill Wendling0f940c92007-12-07 21:42:31 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This pass performs loop invariant code motion on machine instructions. We
11// attempt to remove as much code from the body of a loop as possible.
12//
Dan Gohmanc475c362009-01-15 22:01:38 +000013// This pass does not attempt to throttle itself to limit register pressure.
14// The register allocation phases are expected to perform rematerialization
15// to recover when register pressure is high.
16//
17// This pass is not intended to be a replacement or a complete alternative
18// for the LLVM-IR-level LICM pass. It is only designed to hoist simple
19// constructs that are not exposed before lowering and instruction selection.
20//
Bill Wendling0f940c92007-12-07 21:42:31 +000021//===----------------------------------------------------------------------===//
22
23#define DEBUG_TYPE "machine-licm"
Chris Lattnerac695822008-01-04 06:41:45 +000024#include "llvm/CodeGen/Passes.h"
Bill Wendling0f940c92007-12-07 21:42:31 +000025#include "llvm/CodeGen/MachineDominators.h"
Bill Wendling0f940c92007-12-07 21:42:31 +000026#include "llvm/CodeGen/MachineLoopInfo.h"
Bill Wendling9258cd32008-01-02 19:32:43 +000027#include "llvm/CodeGen/MachineRegisterInfo.h"
Dan Gohman6f0d0242008-02-10 18:45:23 +000028#include "llvm/Target/TargetRegisterInfo.h"
Bill Wendlingefe2be72007-12-11 23:27:51 +000029#include "llvm/Target/TargetInstrInfo.h"
Bill Wendling0f940c92007-12-07 21:42:31 +000030#include "llvm/Target/TargetMachine.h"
Evan Chengaf6949d2009-02-05 08:45:46 +000031#include "llvm/ADT/DenseMap.h"
Chris Lattnerac695822008-01-04 06:41:45 +000032#include "llvm/ADT/Statistic.h"
33#include "llvm/Support/CommandLine.h"
34#include "llvm/Support/Compiler.h"
35#include "llvm/Support/Debug.h"
Bill Wendling0f940c92007-12-07 21:42:31 +000036
37using namespace llvm;
38
Bill Wendling041b3f82007-12-08 23:58:46 +000039STATISTIC(NumHoisted, "Number of machine instructions hoisted out of loops");
Evan Chengaf6949d2009-02-05 08:45:46 +000040STATISTIC(NumCSEed, "Number of hoisted machine instructions CSEed");
Bill Wendlingb48519c2007-12-08 01:47:01 +000041
Bill Wendling0f940c92007-12-07 21:42:31 +000042namespace {
43 class VISIBILITY_HIDDEN MachineLICM : public MachineFunctionPass {
Bill Wendling9258cd32008-01-02 19:32:43 +000044 const TargetMachine *TM;
Bill Wendlingefe2be72007-12-11 23:27:51 +000045 const TargetInstrInfo *TII;
Bill Wendling12ebf142007-12-11 19:40:06 +000046
Bill Wendling0f940c92007-12-07 21:42:31 +000047 // Various analyses that we use...
Bill Wendlinge4fc1cc2008-05-12 19:38:32 +000048 MachineLoopInfo *LI; // Current MachineLoopInfo
49 MachineDominatorTree *DT; // Machine dominator tree for the cur loop
Bill Wendling9258cd32008-01-02 19:32:43 +000050 MachineRegisterInfo *RegInfo; // Machine register information
Bill Wendling0f940c92007-12-07 21:42:31 +000051
Bill Wendling0f940c92007-12-07 21:42:31 +000052 // State that is updated as we process loops
Bill Wendlinge4fc1cc2008-05-12 19:38:32 +000053 bool Changed; // True if a loop is changed.
54 MachineLoop *CurLoop; // The current loop we are working on.
Dan Gohmanc475c362009-01-15 22:01:38 +000055 MachineBasicBlock *CurPreheader; // The preheader for CurLoop.
Evan Chengaf6949d2009-02-05 08:45:46 +000056
57 // For each BB and opcode pair, keep a list of hoisted instructions.
58 DenseMap<std::pair<unsigned, unsigned>,
59 std::vector<const MachineInstr*> > CSEMap;
Bill Wendling0f940c92007-12-07 21:42:31 +000060 public:
61 static char ID; // Pass identification, replacement for typeid
Dan Gohmanae73dc12008-09-04 17:05:41 +000062 MachineLICM() : MachineFunctionPass(&ID) {}
Bill Wendling0f940c92007-12-07 21:42:31 +000063
64 virtual bool runOnMachineFunction(MachineFunction &MF);
65
Dan Gohman72241702008-12-18 01:37:56 +000066 const char *getPassName() const { return "Machine Instruction LICM"; }
67
Bill Wendling074223a2008-03-10 08:13:01 +000068 // FIXME: Loop preheaders?
Bill Wendling0f940c92007-12-07 21:42:31 +000069 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
70 AU.setPreservesCFG();
71 AU.addRequired<MachineLoopInfo>();
72 AU.addRequired<MachineDominatorTree>();
Bill Wendlingd5da7042008-01-04 08:48:49 +000073 AU.addPreserved<MachineLoopInfo>();
74 AU.addPreserved<MachineDominatorTree>();
75 MachineFunctionPass::getAnalysisUsage(AU);
Bill Wendling0f940c92007-12-07 21:42:31 +000076 }
Evan Chengaf6949d2009-02-05 08:45:46 +000077
78 virtual void releaseMemory() {
79 CSEMap.clear();
80 }
81
Bill Wendling0f940c92007-12-07 21:42:31 +000082 private:
Bill Wendling041b3f82007-12-08 23:58:46 +000083 /// IsLoopInvariantInst - Returns true if the instruction is loop
Bill Wendling0f940c92007-12-07 21:42:31 +000084 /// invariant. I.e., all virtual register operands are defined outside of
85 /// the loop, physical registers aren't accessed (explicitly or implicitly),
86 /// and the instruction is hoistable.
87 ///
Bill Wendling041b3f82007-12-08 23:58:46 +000088 bool IsLoopInvariantInst(MachineInstr &I);
Bill Wendling0f940c92007-12-07 21:42:31 +000089
Evan Cheng45e94d62009-02-04 09:19:56 +000090 /// IsProfitableToHoist - Return true if it is potentially profitable to
91 /// hoist the given loop invariant.
92 bool IsProfitableToHoist(MachineInstr &MI);
93
Bill Wendling0f940c92007-12-07 21:42:31 +000094 /// HoistRegion - Walk the specified region of the CFG (defined by all
95 /// blocks dominated by the specified block, and that are in the current
96 /// loop) in depth first order w.r.t the DominatorTree. This allows us to
97 /// visit definitions before uses, allowing us to hoist a loop body in one
98 /// pass without iteration.
99 ///
100 void HoistRegion(MachineDomTreeNode *N);
101
102 /// Hoist - When an instruction is found to only use loop invariant operands
103 /// that is safe to hoist, this instruction is called to do the dirty work.
104 ///
Bill Wendlingb48519c2007-12-08 01:47:01 +0000105 void Hoist(MachineInstr &MI);
Bill Wendling0f940c92007-12-07 21:42:31 +0000106 };
Bill Wendling0f940c92007-12-07 21:42:31 +0000107} // end anonymous namespace
108
Dan Gohman844731a2008-05-13 00:00:25 +0000109char MachineLICM::ID = 0;
110static RegisterPass<MachineLICM>
Bill Wendling8870ce92008-07-07 05:42:27 +0000111X("machinelicm", "Machine Loop Invariant Code Motion");
Dan Gohman844731a2008-05-13 00:00:25 +0000112
Bill Wendling0f940c92007-12-07 21:42:31 +0000113FunctionPass *llvm::createMachineLICMPass() { return new MachineLICM(); }
114
Dan Gohmanc475c362009-01-15 22:01:38 +0000115/// LoopIsOuterMostWithPreheader - Test if the given loop is the outer-most
116/// loop that has a preheader.
117static bool LoopIsOuterMostWithPreheader(MachineLoop *CurLoop) {
118 for (MachineLoop *L = CurLoop->getParentLoop(); L; L = L->getParentLoop())
119 if (L->getLoopPreheader())
120 return false;
121 return true;
122}
123
Bill Wendling0f940c92007-12-07 21:42:31 +0000124/// Hoist expressions out of the specified loop. Note, alias info for inner loop
125/// is not preserved so it is not a good idea to run LICM multiple times on one
126/// loop.
127///
128bool MachineLICM::runOnMachineFunction(MachineFunction &MF) {
Evan Cheng740854b2009-02-05 08:51:13 +0000129 const Function *F = MF.getFunction();
130 if (F->hasFnAttr(Attribute::OptimizeForSize))
131 return false;
132
Bill Wendlinga17ad592007-12-11 22:22:22 +0000133 DOUT << "******** Machine LICM ********\n";
134
Bill Wendling0f940c92007-12-07 21:42:31 +0000135 Changed = false;
Bill Wendlingacb04ec2008-08-31 02:30:23 +0000136 TM = &MF.getTarget();
Bill Wendling9258cd32008-01-02 19:32:43 +0000137 TII = TM->getInstrInfo();
Bill Wendlingacb04ec2008-08-31 02:30:23 +0000138 RegInfo = &MF.getRegInfo();
Bill Wendling0f940c92007-12-07 21:42:31 +0000139
140 // Get our Loop information...
141 LI = &getAnalysis<MachineLoopInfo>();
142 DT = &getAnalysis<MachineDominatorTree>();
143
144 for (MachineLoopInfo::iterator
145 I = LI->begin(), E = LI->end(); I != E; ++I) {
Bill Wendlinga17ad592007-12-11 22:22:22 +0000146 CurLoop = *I;
Bill Wendling0f940c92007-12-07 21:42:31 +0000147
Dan Gohmanc475c362009-01-15 22:01:38 +0000148 // Only visit outer-most preheader-sporting loops.
149 if (!LoopIsOuterMostWithPreheader(CurLoop))
150 continue;
151
152 // Determine the block to which to hoist instructions. If we can't find a
153 // suitable loop preheader, we can't do any hoisting.
154 //
155 // FIXME: We are only hoisting if the basic block coming into this loop
156 // has only one successor. This isn't the case in general because we haven't
157 // broken critical edges or added preheaders.
158 CurPreheader = CurLoop->getLoopPreheader();
159 if (!CurPreheader)
160 continue;
161
162 HoistRegion(DT->getNode(CurLoop->getHeader()));
Bill Wendling0f940c92007-12-07 21:42:31 +0000163 }
164
165 return Changed;
166}
167
Bill Wendling0f940c92007-12-07 21:42:31 +0000168/// HoistRegion - Walk the specified region of the CFG (defined by all blocks
169/// dominated by the specified block, and that are in the current loop) in depth
170/// first order w.r.t the DominatorTree. This allows us to visit definitions
171/// before uses, allowing us to hoist a loop body in one pass without iteration.
172///
173void MachineLICM::HoistRegion(MachineDomTreeNode *N) {
174 assert(N != 0 && "Null dominator tree node?");
175 MachineBasicBlock *BB = N->getBlock();
176
177 // If this subregion is not in the top level loop at all, exit.
178 if (!CurLoop->contains(BB)) return;
179
Dan Gohmanc475c362009-01-15 22:01:38 +0000180 for (MachineBasicBlock::iterator
Evan Chengaf6949d2009-02-05 08:45:46 +0000181 MII = BB->begin(), E = BB->end(); MII != E; ) {
182 MachineBasicBlock::iterator NextMII = MII; ++NextMII;
183 MachineInstr &MI = *MII;
Bill Wendling0f940c92007-12-07 21:42:31 +0000184
Dan Gohmanc475c362009-01-15 22:01:38 +0000185 Hoist(MI);
Evan Chengaf6949d2009-02-05 08:45:46 +0000186
187 MII = NextMII;
Dan Gohmanc475c362009-01-15 22:01:38 +0000188 }
Bill Wendling0f940c92007-12-07 21:42:31 +0000189
190 const std::vector<MachineDomTreeNode*> &Children = N->getChildren();
191
192 for (unsigned I = 0, E = Children.size(); I != E; ++I)
193 HoistRegion(Children[I]);
194}
195
Bill Wendling041b3f82007-12-08 23:58:46 +0000196/// IsLoopInvariantInst - Returns true if the instruction is loop
Bill Wendling0f940c92007-12-07 21:42:31 +0000197/// invariant. I.e., all virtual register operands are defined outside of the
Bill Wendling60ff1a32007-12-20 01:08:10 +0000198/// loop, physical registers aren't accessed explicitly, and there are no side
199/// effects that aren't captured by the operands or other flags.
Bill Wendling0f940c92007-12-07 21:42:31 +0000200///
Bill Wendling041b3f82007-12-08 23:58:46 +0000201bool MachineLICM::IsLoopInvariantInst(MachineInstr &I) {
Chris Lattnera22edc82008-01-10 23:08:24 +0000202 const TargetInstrDesc &TID = I.getDesc();
203
204 // Ignore stuff that we obviously can't hoist.
Dan Gohman237dee12008-12-23 17:28:50 +0000205 if (TID.mayStore() || TID.isCall() || TID.isTerminator() ||
Chris Lattnera22edc82008-01-10 23:08:24 +0000206 TID.hasUnmodeledSideEffects())
207 return false;
Evan Cheng9b61f332009-02-04 07:17:49 +0000208
Chris Lattnera22edc82008-01-10 23:08:24 +0000209 if (TID.mayLoad()) {
Bill Wendlinge4fc1cc2008-05-12 19:38:32 +0000210 // Okay, this instruction does a load. As a refinement, we allow the target
211 // to decide whether the loaded value is actually a constant. If so, we can
212 // actually use it as a load.
Evan Cheng45e94d62009-02-04 09:19:56 +0000213 if (!TII->isInvariantLoad(&I))
Chris Lattnera22edc82008-01-10 23:08:24 +0000214 // FIXME: we should be able to sink loads with no other side effects if
215 // there is nothing that can change memory from here until the end of
Bill Wendlinge4fc1cc2008-05-12 19:38:32 +0000216 // block. This is a trivial form of alias analysis.
Chris Lattnera22edc82008-01-10 23:08:24 +0000217 return false;
Chris Lattnera22edc82008-01-10 23:08:24 +0000218 }
Bill Wendling074223a2008-03-10 08:13:01 +0000219
Bill Wendling280f4562007-12-18 21:38:04 +0000220 DEBUG({
221 DOUT << "--- Checking if we can hoist " << I;
Chris Lattner749c6f62008-01-07 07:27:27 +0000222 if (I.getDesc().getImplicitUses()) {
Bill Wendling280f4562007-12-18 21:38:04 +0000223 DOUT << " * Instruction has implicit uses:\n";
224
Dan Gohman6f0d0242008-02-10 18:45:23 +0000225 const TargetRegisterInfo *TRI = TM->getRegisterInfo();
Chris Lattner749c6f62008-01-07 07:27:27 +0000226 for (const unsigned *ImpUses = I.getDesc().getImplicitUses();
Chris Lattner69244302008-01-07 01:56:04 +0000227 *ImpUses; ++ImpUses)
Bill Wendlinge6d088a2008-02-26 21:47:57 +0000228 DOUT << " -> " << TRI->getName(*ImpUses) << "\n";
Bill Wendling280f4562007-12-18 21:38:04 +0000229 }
230
Chris Lattner749c6f62008-01-07 07:27:27 +0000231 if (I.getDesc().getImplicitDefs()) {
Bill Wendling280f4562007-12-18 21:38:04 +0000232 DOUT << " * Instruction has implicit defines:\n";
233
Dan Gohman6f0d0242008-02-10 18:45:23 +0000234 const TargetRegisterInfo *TRI = TM->getRegisterInfo();
Chris Lattner749c6f62008-01-07 07:27:27 +0000235 for (const unsigned *ImpDefs = I.getDesc().getImplicitDefs();
Chris Lattner69244302008-01-07 01:56:04 +0000236 *ImpDefs; ++ImpDefs)
Bill Wendlinge6d088a2008-02-26 21:47:57 +0000237 DOUT << " -> " << TRI->getName(*ImpDefs) << "\n";
Bill Wendling280f4562007-12-18 21:38:04 +0000238 }
Bill Wendling280f4562007-12-18 21:38:04 +0000239 });
240
Bill Wendlingd3361e92008-08-18 00:33:49 +0000241 if (I.getDesc().getImplicitDefs() || I.getDesc().getImplicitUses()) {
242 DOUT << "Cannot hoist with implicit defines or uses\n";
243 return false;
244 }
245
Bill Wendlinge4fc1cc2008-05-12 19:38:32 +0000246 // The instruction is loop invariant if all of its operands are.
Bill Wendling0f940c92007-12-07 21:42:31 +0000247 for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) {
248 const MachineOperand &MO = I.getOperand(i);
249
Dan Gohmand735b802008-10-03 15:45:36 +0000250 if (!MO.isReg())
Bill Wendlingfb018d02008-08-20 20:32:05 +0000251 continue;
252
Dan Gohmanc475c362009-01-15 22:01:38 +0000253 unsigned Reg = MO.getReg();
254 if (Reg == 0) continue;
255
256 // Don't hoist an instruction that uses or defines a physical register.
257 if (TargetRegisterInfo::isPhysicalRegister(Reg))
Bill Wendlingfb018d02008-08-20 20:32:05 +0000258 return false;
259
260 if (!MO.isUse())
Bill Wendling0f940c92007-12-07 21:42:31 +0000261 continue;
262
Bill Wendlinge4fc1cc2008-05-12 19:38:32 +0000263 assert(RegInfo->getVRegDef(Reg) &&
264 "Machine instr not mapped for this vreg?!");
Bill Wendling0f940c92007-12-07 21:42:31 +0000265
266 // If the loop contains the definition of an operand, then the instruction
267 // isn't loop invariant.
Bill Wendling9258cd32008-01-02 19:32:43 +0000268 if (CurLoop->contains(RegInfo->getVRegDef(Reg)->getParent()))
Bill Wendling0f940c92007-12-07 21:42:31 +0000269 return false;
270 }
271
272 // If we got this far, the instruction is loop invariant!
273 return true;
274}
275
Evan Chengaf6949d2009-02-05 08:45:46 +0000276
277/// HasPHIUses - Return true if the specified register has any PHI use.
278static bool HasPHIUses(unsigned Reg, MachineRegisterInfo *RegInfo) {
Evan Cheng45e94d62009-02-04 09:19:56 +0000279 for (MachineRegisterInfo::use_iterator UI = RegInfo->use_begin(Reg),
280 UE = RegInfo->use_end(); UI != UE; ++UI) {
281 MachineInstr *UseMI = &*UI;
Evan Chengaf6949d2009-02-05 08:45:46 +0000282 if (UseMI->getOpcode() == TargetInstrInfo::PHI)
283 return true;
Evan Cheng45e94d62009-02-04 09:19:56 +0000284 }
Evan Chengaf6949d2009-02-05 08:45:46 +0000285 return false;
Evan Cheng45e94d62009-02-04 09:19:56 +0000286}
287
288/// IsProfitableToHoist - Return true if it is potentially profitable to hoist
289/// the given loop invariant.
290bool MachineLICM::IsProfitableToHoist(MachineInstr &MI) {
291 const TargetInstrDesc &TID = MI.getDesc();
292
Evan Cheng45e94d62009-02-04 09:19:56 +0000293 // FIXME: For now, only hoist re-materilizable instructions. LICM will
294 // increase register pressure. We want to make sure it doesn't increase
295 // spilling.
Evan Cheng5caa8832009-02-04 09:21:58 +0000296 if (!TID.mayLoad() && (!TID.isRematerializable() ||
297 !TII->isTriviallyReMaterializable(&MI)))
Evan Cheng45e94d62009-02-04 09:19:56 +0000298 return false;
299
Evan Chengaf6949d2009-02-05 08:45:46 +0000300 // If result(s) of this instruction is used by PHIs, then don't hoist it.
301 // The presence of joins makes it difficult for current register allocator
302 // implementation to perform remat.
Evan Cheng45e94d62009-02-04 09:19:56 +0000303 for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
304 const MachineOperand &MO = MI.getOperand(i);
305 if (!MO.isReg() || !MO.isDef())
306 continue;
Evan Chengaf6949d2009-02-05 08:45:46 +0000307 if (HasPHIUses(MO.getReg(), RegInfo))
308 return false;
Evan Cheng45e94d62009-02-04 09:19:56 +0000309 }
Evan Chengaf6949d2009-02-05 08:45:46 +0000310
311 return true;
312}
313
314static const MachineInstr *LookForDuplicate(const MachineInstr *MI,
315 std::vector<const MachineInstr*> &PrevMIs) {
316 unsigned NumOps = MI->getNumOperands();
317 for (unsigned i = 0, e = PrevMIs.size(); i != e; ++i) {
318 const MachineInstr *PrevMI = PrevMIs[i];
319 unsigned NumOps2 = PrevMI->getNumOperands();
320 if (NumOps != NumOps2)
321 continue;
322 bool IsSame = true;
323 for (unsigned j = 0; j != NumOps; ++j) {
324 const MachineOperand &MO = MI->getOperand(j);
325 if (MO.isReg() && MO.isDef())
326 continue;
327 if (!MO.isIdenticalTo(PrevMI->getOperand(j))) {
328 IsSame = false;
329 break;
330 }
331 }
332 if (IsSame)
333 return PrevMI;
334 }
335 return 0;
Evan Cheng45e94d62009-02-04 09:19:56 +0000336}
337
Bill Wendlinge4fc1cc2008-05-12 19:38:32 +0000338/// Hoist - When an instruction is found to use only loop invariant operands
339/// that are safe to hoist, this instruction is called to do the dirty work.
Bill Wendling0f940c92007-12-07 21:42:31 +0000340///
Bill Wendlingb48519c2007-12-08 01:47:01 +0000341void MachineLICM::Hoist(MachineInstr &MI) {
Bill Wendling041b3f82007-12-08 23:58:46 +0000342 if (!IsLoopInvariantInst(MI)) return;
Evan Cheng45e94d62009-02-04 09:19:56 +0000343 if (!IsProfitableToHoist(MI)) return;
Bill Wendling0f940c92007-12-07 21:42:31 +0000344
Dan Gohmanc475c362009-01-15 22:01:38 +0000345 // Now move the instructions to the predecessor, inserting it before any
346 // terminator instructions.
347 DEBUG({
348 DOUT << "Hoisting " << MI;
349 if (CurPreheader->getBasicBlock())
350 DOUT << " to MachineBasicBlock "
351 << CurPreheader->getBasicBlock()->getName();
352 if (MI.getParent()->getBasicBlock())
353 DOUT << " from MachineBasicBlock "
354 << MI.getParent()->getBasicBlock()->getName();
355 DOUT << "\n";
356 });
Bill Wendling0f940c92007-12-07 21:42:31 +0000357
Evan Chengaf6949d2009-02-05 08:45:46 +0000358 // Look for opportunity to CSE the hoisted instruction.
359 std::pair<unsigned, unsigned> BBOpcPair =
360 std::make_pair(CurPreheader->getNumber(), MI.getOpcode());
361 DenseMap<std::pair<unsigned, unsigned>,
362 std::vector<const MachineInstr*> >::iterator CI = CSEMap.find(BBOpcPair);
363 bool DoneCSE = false;
364 if (CI != CSEMap.end()) {
365 const MachineInstr *Dup = LookForDuplicate(&MI, CI->second);
366 if (Dup) {
367 DOUT << "CSEing " << MI;
368 DOUT << " with " << *Dup;
369 for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
370 const MachineOperand &MO = MI.getOperand(i);
371 if (MO.isReg() && MO.isDef())
372 RegInfo->replaceRegWith(MO.getReg(), Dup->getOperand(i).getReg());
373 }
374 MI.eraseFromParent();
375 DoneCSE = true;
376 ++NumCSEed;
377 }
378 }
379
380 // Otherwise, splice the instruction to the preheader.
381 if (!DoneCSE) {
382 CurPreheader->splice(CurPreheader->getFirstTerminator(),
383 MI.getParent(), &MI);
384 // Add to the CSE map.
385 if (CI != CSEMap.end())
386 CI->second.push_back(&MI);
387 else {
388 std::vector<const MachineInstr*> CSEMIs;
389 CSEMIs.push_back(&MI);
390 CSEMap.insert(std::make_pair(BBOpcPair, CSEMIs));
391 }
392 }
Bill Wendling0f940c92007-12-07 21:42:31 +0000393
Dan Gohmanc475c362009-01-15 22:01:38 +0000394 ++NumHoisted;
Bill Wendling0f940c92007-12-07 21:42:31 +0000395 Changed = true;
Bill Wendling0f940c92007-12-07 21:42:31 +0000396}