Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 1 | //===-- MachineLICM.cpp - Machine Loop Invariant Code Motion Pass ---------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 7 | // |
| 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 Gohman | c475c36 | 2009-01-15 22:01:38 +0000 | [diff] [blame] | 13 | // 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 Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 21 | //===----------------------------------------------------------------------===// |
| 22 | |
| 23 | #define DEBUG_TYPE "machine-licm" |
Chris Lattner | ac69582 | 2008-01-04 06:41:45 +0000 | [diff] [blame] | 24 | #include "llvm/CodeGen/Passes.h" |
Evan Cheng | 78e5c11 | 2009-11-07 03:52:02 +0000 | [diff] [blame] | 25 | #include "llvm/CodeGen/MachineConstantPool.h" |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 26 | #include "llvm/CodeGen/MachineDominators.h" |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 27 | #include "llvm/CodeGen/MachineLoopInfo.h" |
Dan Gohman | 589f1f5 | 2009-10-28 03:21:57 +0000 | [diff] [blame] | 28 | #include "llvm/CodeGen/MachineMemOperand.h" |
Bill Wendling | 9258cd3 | 2008-01-02 19:32:43 +0000 | [diff] [blame] | 29 | #include "llvm/CodeGen/MachineRegisterInfo.h" |
Dan Gohman | 589f1f5 | 2009-10-28 03:21:57 +0000 | [diff] [blame] | 30 | #include "llvm/CodeGen/PseudoSourceValue.h" |
Dan Gohman | 6f0d024 | 2008-02-10 18:45:23 +0000 | [diff] [blame] | 31 | #include "llvm/Target/TargetRegisterInfo.h" |
Bill Wendling | efe2be7 | 2007-12-11 23:27:51 +0000 | [diff] [blame] | 32 | #include "llvm/Target/TargetInstrInfo.h" |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 33 | #include "llvm/Target/TargetMachine.h" |
Dan Gohman | e33f44c | 2009-10-07 17:38:06 +0000 | [diff] [blame] | 34 | #include "llvm/Analysis/AliasAnalysis.h" |
Evan Cheng | af6949d | 2009-02-05 08:45:46 +0000 | [diff] [blame] | 35 | #include "llvm/ADT/DenseMap.h" |
Chris Lattner | ac69582 | 2008-01-04 06:41:45 +0000 | [diff] [blame] | 36 | #include "llvm/ADT/Statistic.h" |
Chris Lattner | ac69582 | 2008-01-04 06:41:45 +0000 | [diff] [blame] | 37 | #include "llvm/Support/Debug.h" |
Daniel Dunbar | ce63ffb | 2009-07-25 00:23:56 +0000 | [diff] [blame] | 38 | #include "llvm/Support/raw_ostream.h" |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 39 | |
| 40 | using namespace llvm; |
| 41 | |
Bill Wendling | 041b3f8 | 2007-12-08 23:58:46 +0000 | [diff] [blame] | 42 | STATISTIC(NumHoisted, "Number of machine instructions hoisted out of loops"); |
Evan Cheng | af6949d | 2009-02-05 08:45:46 +0000 | [diff] [blame] | 43 | STATISTIC(NumCSEed, "Number of hoisted machine instructions CSEed"); |
Bill Wendling | b48519c | 2007-12-08 01:47:01 +0000 | [diff] [blame] | 44 | |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 45 | namespace { |
Nick Lewycky | 6726b6d | 2009-10-25 06:33:48 +0000 | [diff] [blame] | 46 | class MachineLICM : public MachineFunctionPass { |
Evan Cheng | 78e5c11 | 2009-11-07 03:52:02 +0000 | [diff] [blame] | 47 | MachineConstantPool *MCP; |
Bill Wendling | 9258cd3 | 2008-01-02 19:32:43 +0000 | [diff] [blame] | 48 | const TargetMachine *TM; |
Bill Wendling | efe2be7 | 2007-12-11 23:27:51 +0000 | [diff] [blame] | 49 | const TargetInstrInfo *TII; |
Dan Gohman | a8fb336 | 2009-09-25 23:58:45 +0000 | [diff] [blame] | 50 | const TargetRegisterInfo *TRI; |
Dan Gohman | 45094e3 | 2009-09-26 02:34:00 +0000 | [diff] [blame] | 51 | BitVector AllocatableSet; |
Bill Wendling | 12ebf14 | 2007-12-11 19:40:06 +0000 | [diff] [blame] | 52 | |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 53 | // Various analyses that we use... |
Dan Gohman | e33f44c | 2009-10-07 17:38:06 +0000 | [diff] [blame] | 54 | AliasAnalysis *AA; // Alias analysis info. |
Bill Wendling | e4fc1cc | 2008-05-12 19:38:32 +0000 | [diff] [blame] | 55 | MachineLoopInfo *LI; // Current MachineLoopInfo |
| 56 | MachineDominatorTree *DT; // Machine dominator tree for the cur loop |
Bill Wendling | 9258cd3 | 2008-01-02 19:32:43 +0000 | [diff] [blame] | 57 | MachineRegisterInfo *RegInfo; // Machine register information |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 58 | |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 59 | // State that is updated as we process loops |
Bill Wendling | e4fc1cc | 2008-05-12 19:38:32 +0000 | [diff] [blame] | 60 | bool Changed; // True if a loop is changed. |
Evan Cheng | 777c6b7 | 2009-11-03 21:40:02 +0000 | [diff] [blame] | 61 | bool FirstInLoop; // True if it's the first LICM in the loop. |
Bill Wendling | e4fc1cc | 2008-05-12 19:38:32 +0000 | [diff] [blame] | 62 | MachineLoop *CurLoop; // The current loop we are working on. |
Dan Gohman | c475c36 | 2009-01-15 22:01:38 +0000 | [diff] [blame] | 63 | MachineBasicBlock *CurPreheader; // The preheader for CurLoop. |
Evan Cheng | af6949d | 2009-02-05 08:45:46 +0000 | [diff] [blame] | 64 | |
Evan Cheng | 777c6b7 | 2009-11-03 21:40:02 +0000 | [diff] [blame] | 65 | // For each opcode, keep a list of potentail CSE instructions. |
| 66 | DenseMap<unsigned, std::vector<const MachineInstr*> > CSEMap; |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 67 | public: |
| 68 | static char ID; // Pass identification, replacement for typeid |
Dan Gohman | ae73dc1 | 2008-09-04 17:05:41 +0000 | [diff] [blame] | 69 | MachineLICM() : MachineFunctionPass(&ID) {} |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 70 | |
| 71 | virtual bool runOnMachineFunction(MachineFunction &MF); |
| 72 | |
Dan Gohman | 7224170 | 2008-12-18 01:37:56 +0000 | [diff] [blame] | 73 | const char *getPassName() const { return "Machine Instruction LICM"; } |
| 74 | |
Bill Wendling | 074223a | 2008-03-10 08:13:01 +0000 | [diff] [blame] | 75 | // FIXME: Loop preheaders? |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 76 | virtual void getAnalysisUsage(AnalysisUsage &AU) const { |
| 77 | AU.setPreservesCFG(); |
| 78 | AU.addRequired<MachineLoopInfo>(); |
| 79 | AU.addRequired<MachineDominatorTree>(); |
Dan Gohman | e33f44c | 2009-10-07 17:38:06 +0000 | [diff] [blame] | 80 | AU.addRequired<AliasAnalysis>(); |
Bill Wendling | d5da704 | 2008-01-04 08:48:49 +0000 | [diff] [blame] | 81 | AU.addPreserved<MachineLoopInfo>(); |
| 82 | AU.addPreserved<MachineDominatorTree>(); |
| 83 | MachineFunctionPass::getAnalysisUsage(AU); |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 84 | } |
Evan Cheng | af6949d | 2009-02-05 08:45:46 +0000 | [diff] [blame] | 85 | |
| 86 | virtual void releaseMemory() { |
| 87 | CSEMap.clear(); |
| 88 | } |
| 89 | |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 90 | private: |
Bill Wendling | 041b3f8 | 2007-12-08 23:58:46 +0000 | [diff] [blame] | 91 | /// IsLoopInvariantInst - Returns true if the instruction is loop |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 92 | /// invariant. I.e., all virtual register operands are defined outside of |
| 93 | /// the loop, physical registers aren't accessed (explicitly or implicitly), |
| 94 | /// and the instruction is hoistable. |
| 95 | /// |
Bill Wendling | 041b3f8 | 2007-12-08 23:58:46 +0000 | [diff] [blame] | 96 | bool IsLoopInvariantInst(MachineInstr &I); |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 97 | |
Evan Cheng | 45e94d6 | 2009-02-04 09:19:56 +0000 | [diff] [blame] | 98 | /// IsProfitableToHoist - Return true if it is potentially profitable to |
| 99 | /// hoist the given loop invariant. |
Evan Cheng | c26abd9 | 2009-11-20 23:31:34 +0000 | [diff] [blame] | 100 | bool IsProfitableToHoist(MachineInstr &MI); |
Evan Cheng | 45e94d6 | 2009-02-04 09:19:56 +0000 | [diff] [blame] | 101 | |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 102 | /// HoistRegion - Walk the specified region of the CFG (defined by all |
| 103 | /// blocks dominated by the specified block, and that are in the current |
| 104 | /// loop) in depth first order w.r.t the DominatorTree. This allows us to |
| 105 | /// visit definitions before uses, allowing us to hoist a loop body in one |
| 106 | /// pass without iteration. |
| 107 | /// |
| 108 | void HoistRegion(MachineDomTreeNode *N); |
| 109 | |
Evan Cheng | 87b75ba | 2009-11-20 19:55:37 +0000 | [diff] [blame] | 110 | /// isLoadFromConstantMemory - Return true if the given instruction is a |
| 111 | /// load from constant memory. |
| 112 | bool isLoadFromConstantMemory(MachineInstr *MI); |
| 113 | |
Dan Gohman | 5c95230 | 2009-10-29 17:47:20 +0000 | [diff] [blame] | 114 | /// ExtractHoistableLoad - Unfold a load from the given machineinstr if |
| 115 | /// the load itself could be hoisted. Return the unfolded and hoistable |
| 116 | /// load, or null if the load couldn't be unfolded or if it wouldn't |
| 117 | /// be hoistable. |
| 118 | MachineInstr *ExtractHoistableLoad(MachineInstr *MI); |
| 119 | |
Evan Cheng | 78e5c11 | 2009-11-07 03:52:02 +0000 | [diff] [blame] | 120 | /// LookForDuplicate - Find an instruction amount PrevMIs that is a |
| 121 | /// duplicate of MI. Return this instruction if it's found. |
| 122 | const MachineInstr *LookForDuplicate(const MachineInstr *MI, |
| 123 | std::vector<const MachineInstr*> &PrevMIs); |
| 124 | |
Evan Cheng | 9fb744e | 2009-11-05 00:51:13 +0000 | [diff] [blame] | 125 | /// EliminateCSE - Given a LICM'ed instruction, look for an instruction on |
| 126 | /// the preheader that compute the same value. If it's found, do a RAU on |
| 127 | /// with the definition of the existing instruction rather than hoisting |
| 128 | /// the instruction to the preheader. |
| 129 | bool EliminateCSE(MachineInstr *MI, |
| 130 | DenseMap<unsigned, std::vector<const MachineInstr*> >::iterator &CI); |
| 131 | |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 132 | /// Hoist - When an instruction is found to only use loop invariant operands |
| 133 | /// that is safe to hoist, this instruction is called to do the dirty work. |
| 134 | /// |
Dan Gohman | 589f1f5 | 2009-10-28 03:21:57 +0000 | [diff] [blame] | 135 | void Hoist(MachineInstr *MI); |
Evan Cheng | 777c6b7 | 2009-11-03 21:40:02 +0000 | [diff] [blame] | 136 | |
| 137 | /// InitCSEMap - Initialize the CSE map with instructions that are in the |
| 138 | /// current loop preheader that may become duplicates of instructions that |
| 139 | /// are hoisted out of the loop. |
| 140 | void InitCSEMap(MachineBasicBlock *BB); |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 141 | }; |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 142 | } // end anonymous namespace |
| 143 | |
Dan Gohman | 844731a | 2008-05-13 00:00:25 +0000 | [diff] [blame] | 144 | char MachineLICM::ID = 0; |
| 145 | static RegisterPass<MachineLICM> |
Bill Wendling | 8870ce9 | 2008-07-07 05:42:27 +0000 | [diff] [blame] | 146 | X("machinelicm", "Machine Loop Invariant Code Motion"); |
Dan Gohman | 844731a | 2008-05-13 00:00:25 +0000 | [diff] [blame] | 147 | |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 148 | FunctionPass *llvm::createMachineLICMPass() { return new MachineLICM(); } |
| 149 | |
Dan Gohman | c475c36 | 2009-01-15 22:01:38 +0000 | [diff] [blame] | 150 | /// LoopIsOuterMostWithPreheader - Test if the given loop is the outer-most |
| 151 | /// loop that has a preheader. |
| 152 | static bool LoopIsOuterMostWithPreheader(MachineLoop *CurLoop) { |
| 153 | for (MachineLoop *L = CurLoop->getParentLoop(); L; L = L->getParentLoop()) |
| 154 | if (L->getLoopPreheader()) |
| 155 | return false; |
| 156 | return true; |
| 157 | } |
| 158 | |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 159 | /// Hoist expressions out of the specified loop. Note, alias info for inner loop |
| 160 | /// is not preserved so it is not a good idea to run LICM multiple times on one |
| 161 | /// loop. |
| 162 | /// |
| 163 | bool MachineLICM::runOnMachineFunction(MachineFunction &MF) { |
David Greene | 65a41eb | 2010-01-05 00:03:48 +0000 | [diff] [blame] | 164 | DEBUG(dbgs() << "******** Machine LICM ********\n"); |
Bill Wendling | a17ad59 | 2007-12-11 22:22:22 +0000 | [diff] [blame] | 165 | |
Evan Cheng | 777c6b7 | 2009-11-03 21:40:02 +0000 | [diff] [blame] | 166 | Changed = FirstInLoop = false; |
Evan Cheng | 78e5c11 | 2009-11-07 03:52:02 +0000 | [diff] [blame] | 167 | MCP = MF.getConstantPool(); |
Bill Wendling | acb04ec | 2008-08-31 02:30:23 +0000 | [diff] [blame] | 168 | TM = &MF.getTarget(); |
Bill Wendling | 9258cd3 | 2008-01-02 19:32:43 +0000 | [diff] [blame] | 169 | TII = TM->getInstrInfo(); |
Dan Gohman | a8fb336 | 2009-09-25 23:58:45 +0000 | [diff] [blame] | 170 | TRI = TM->getRegisterInfo(); |
Bill Wendling | acb04ec | 2008-08-31 02:30:23 +0000 | [diff] [blame] | 171 | RegInfo = &MF.getRegInfo(); |
Dan Gohman | 45094e3 | 2009-09-26 02:34:00 +0000 | [diff] [blame] | 172 | AllocatableSet = TRI->getAllocatableSet(MF); |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 173 | |
| 174 | // Get our Loop information... |
| 175 | LI = &getAnalysis<MachineLoopInfo>(); |
| 176 | DT = &getAnalysis<MachineDominatorTree>(); |
Dan Gohman | e33f44c | 2009-10-07 17:38:06 +0000 | [diff] [blame] | 177 | AA = &getAnalysis<AliasAnalysis>(); |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 178 | |
Evan Cheng | 777c6b7 | 2009-11-03 21:40:02 +0000 | [diff] [blame] | 179 | for (MachineLoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I) { |
Bill Wendling | a17ad59 | 2007-12-11 22:22:22 +0000 | [diff] [blame] | 180 | CurLoop = *I; |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 181 | |
Dan Gohman | c475c36 | 2009-01-15 22:01:38 +0000 | [diff] [blame] | 182 | // Only visit outer-most preheader-sporting loops. |
| 183 | if (!LoopIsOuterMostWithPreheader(CurLoop)) |
| 184 | continue; |
| 185 | |
| 186 | // Determine the block to which to hoist instructions. If we can't find a |
| 187 | // suitable loop preheader, we can't do any hoisting. |
| 188 | // |
| 189 | // FIXME: We are only hoisting if the basic block coming into this loop |
| 190 | // has only one successor. This isn't the case in general because we haven't |
| 191 | // broken critical edges or added preheaders. |
| 192 | CurPreheader = CurLoop->getLoopPreheader(); |
| 193 | if (!CurPreheader) |
| 194 | continue; |
| 195 | |
Evan Cheng | 777c6b7 | 2009-11-03 21:40:02 +0000 | [diff] [blame] | 196 | // CSEMap is initialized for loop header when the first instruction is |
| 197 | // being hoisted. |
| 198 | FirstInLoop = true; |
Dan Gohman | c475c36 | 2009-01-15 22:01:38 +0000 | [diff] [blame] | 199 | HoistRegion(DT->getNode(CurLoop->getHeader())); |
Evan Cheng | 777c6b7 | 2009-11-03 21:40:02 +0000 | [diff] [blame] | 200 | CSEMap.clear(); |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | return Changed; |
| 204 | } |
| 205 | |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 206 | /// HoistRegion - Walk the specified region of the CFG (defined by all blocks |
| 207 | /// dominated by the specified block, and that are in the current loop) in depth |
| 208 | /// first order w.r.t the DominatorTree. This allows us to visit definitions |
| 209 | /// before uses, allowing us to hoist a loop body in one pass without iteration. |
| 210 | /// |
| 211 | void MachineLICM::HoistRegion(MachineDomTreeNode *N) { |
| 212 | assert(N != 0 && "Null dominator tree node?"); |
| 213 | MachineBasicBlock *BB = N->getBlock(); |
| 214 | |
| 215 | // If this subregion is not in the top level loop at all, exit. |
| 216 | if (!CurLoop->contains(BB)) return; |
| 217 | |
Dan Gohman | c475c36 | 2009-01-15 22:01:38 +0000 | [diff] [blame] | 218 | for (MachineBasicBlock::iterator |
Evan Cheng | af6949d | 2009-02-05 08:45:46 +0000 | [diff] [blame] | 219 | MII = BB->begin(), E = BB->end(); MII != E; ) { |
| 220 | MachineBasicBlock::iterator NextMII = MII; ++NextMII; |
Evan Cheng | 777c6b7 | 2009-11-03 21:40:02 +0000 | [diff] [blame] | 221 | Hoist(&*MII); |
Evan Cheng | af6949d | 2009-02-05 08:45:46 +0000 | [diff] [blame] | 222 | MII = NextMII; |
Dan Gohman | c475c36 | 2009-01-15 22:01:38 +0000 | [diff] [blame] | 223 | } |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 224 | |
| 225 | const std::vector<MachineDomTreeNode*> &Children = N->getChildren(); |
| 226 | |
| 227 | for (unsigned I = 0, E = Children.size(); I != E; ++I) |
| 228 | HoistRegion(Children[I]); |
| 229 | } |
| 230 | |
Bill Wendling | 041b3f8 | 2007-12-08 23:58:46 +0000 | [diff] [blame] | 231 | /// IsLoopInvariantInst - Returns true if the instruction is loop |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 232 | /// invariant. I.e., all virtual register operands are defined outside of the |
Bill Wendling | 60ff1a3 | 2007-12-20 01:08:10 +0000 | [diff] [blame] | 233 | /// loop, physical registers aren't accessed explicitly, and there are no side |
| 234 | /// effects that aren't captured by the operands or other flags. |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 235 | /// |
Bill Wendling | 041b3f8 | 2007-12-08 23:58:46 +0000 | [diff] [blame] | 236 | bool MachineLICM::IsLoopInvariantInst(MachineInstr &I) { |
Chris Lattner | a22edc8 | 2008-01-10 23:08:24 +0000 | [diff] [blame] | 237 | const TargetInstrDesc &TID = I.getDesc(); |
| 238 | |
| 239 | // Ignore stuff that we obviously can't hoist. |
Dan Gohman | 237dee1 | 2008-12-23 17:28:50 +0000 | [diff] [blame] | 240 | if (TID.mayStore() || TID.isCall() || TID.isTerminator() || |
Chris Lattner | a22edc8 | 2008-01-10 23:08:24 +0000 | [diff] [blame] | 241 | TID.hasUnmodeledSideEffects()) |
| 242 | return false; |
Evan Cheng | 9b61f33 | 2009-02-04 07:17:49 +0000 | [diff] [blame] | 243 | |
Chris Lattner | a22edc8 | 2008-01-10 23:08:24 +0000 | [diff] [blame] | 244 | if (TID.mayLoad()) { |
Bill Wendling | e4fc1cc | 2008-05-12 19:38:32 +0000 | [diff] [blame] | 245 | // Okay, this instruction does a load. As a refinement, we allow the target |
| 246 | // to decide whether the loaded value is actually a constant. If so, we can |
| 247 | // actually use it as a load. |
Dan Gohman | e33f44c | 2009-10-07 17:38:06 +0000 | [diff] [blame] | 248 | if (!I.isInvariantLoad(AA)) |
Evan Cheng | 7adcdc3 | 2009-11-17 19:19:01 +0000 | [diff] [blame] | 249 | // FIXME: we should be able to hoist loads with no other side effects if |
| 250 | // there are no other instructions which can change memory in this loop. |
| 251 | // This is a trivial form of alias analysis. |
Chris Lattner | a22edc8 | 2008-01-10 23:08:24 +0000 | [diff] [blame] | 252 | return false; |
Chris Lattner | a22edc8 | 2008-01-10 23:08:24 +0000 | [diff] [blame] | 253 | } |
Bill Wendling | 074223a | 2008-03-10 08:13:01 +0000 | [diff] [blame] | 254 | |
Bill Wendling | e4fc1cc | 2008-05-12 19:38:32 +0000 | [diff] [blame] | 255 | // The instruction is loop invariant if all of its operands are. |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 256 | for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) { |
| 257 | const MachineOperand &MO = I.getOperand(i); |
| 258 | |
Dan Gohman | d735b80 | 2008-10-03 15:45:36 +0000 | [diff] [blame] | 259 | if (!MO.isReg()) |
Bill Wendling | fb018d0 | 2008-08-20 20:32:05 +0000 | [diff] [blame] | 260 | continue; |
| 261 | |
Dan Gohman | c475c36 | 2009-01-15 22:01:38 +0000 | [diff] [blame] | 262 | unsigned Reg = MO.getReg(); |
| 263 | if (Reg == 0) continue; |
| 264 | |
| 265 | // Don't hoist an instruction that uses or defines a physical register. |
Dan Gohman | a8fb336 | 2009-09-25 23:58:45 +0000 | [diff] [blame] | 266 | if (TargetRegisterInfo::isPhysicalRegister(Reg)) { |
Dan Gohman | a8fb336 | 2009-09-25 23:58:45 +0000 | [diff] [blame] | 267 | if (MO.isUse()) { |
| 268 | // If the physreg has no defs anywhere, it's just an ambient register |
Dan Gohman | 45094e3 | 2009-09-26 02:34:00 +0000 | [diff] [blame] | 269 | // and we can freely move its uses. Alternatively, if it's allocatable, |
| 270 | // it could get allocated to something with a def during allocation. |
Dan Gohman | a8fb336 | 2009-09-25 23:58:45 +0000 | [diff] [blame] | 271 | if (!RegInfo->def_empty(Reg)) |
| 272 | return false; |
Dan Gohman | 45094e3 | 2009-09-26 02:34:00 +0000 | [diff] [blame] | 273 | if (AllocatableSet.test(Reg)) |
| 274 | return false; |
Dan Gohman | a8fb336 | 2009-09-25 23:58:45 +0000 | [diff] [blame] | 275 | // Check for a def among the register's aliases too. |
Dan Gohman | 45094e3 | 2009-09-26 02:34:00 +0000 | [diff] [blame] | 276 | for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias) { |
| 277 | unsigned AliasReg = *Alias; |
| 278 | if (!RegInfo->def_empty(AliasReg)) |
Dan Gohman | a8fb336 | 2009-09-25 23:58:45 +0000 | [diff] [blame] | 279 | return false; |
Dan Gohman | 45094e3 | 2009-09-26 02:34:00 +0000 | [diff] [blame] | 280 | if (AllocatableSet.test(AliasReg)) |
| 281 | return false; |
| 282 | } |
Dan Gohman | a8fb336 | 2009-09-25 23:58:45 +0000 | [diff] [blame] | 283 | // Otherwise it's safe to move. |
| 284 | continue; |
| 285 | } else if (!MO.isDead()) { |
| 286 | // A def that isn't dead. We can't move it. |
| 287 | return false; |
Dan Gohman | a363a9b | 2010-02-28 00:08:44 +0000 | [diff] [blame^] | 288 | } else if (CurLoop->getHeader()->isLiveIn(Reg)) { |
| 289 | // If the reg is live into the loop, we can't hoist an instruction |
| 290 | // which would clobber it. |
| 291 | return false; |
Dan Gohman | a8fb336 | 2009-09-25 23:58:45 +0000 | [diff] [blame] | 292 | } |
| 293 | } |
Bill Wendling | fb018d0 | 2008-08-20 20:32:05 +0000 | [diff] [blame] | 294 | |
| 295 | if (!MO.isUse()) |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 296 | continue; |
| 297 | |
Bill Wendling | e4fc1cc | 2008-05-12 19:38:32 +0000 | [diff] [blame] | 298 | assert(RegInfo->getVRegDef(Reg) && |
| 299 | "Machine instr not mapped for this vreg?!"); |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 300 | |
| 301 | // If the loop contains the definition of an operand, then the instruction |
| 302 | // isn't loop invariant. |
Dan Gohman | 92329c7 | 2009-12-18 01:24:09 +0000 | [diff] [blame] | 303 | if (CurLoop->contains(RegInfo->getVRegDef(Reg))) |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 304 | return false; |
| 305 | } |
| 306 | |
| 307 | // If we got this far, the instruction is loop invariant! |
| 308 | return true; |
| 309 | } |
| 310 | |
Evan Cheng | af6949d | 2009-02-05 08:45:46 +0000 | [diff] [blame] | 311 | |
| 312 | /// HasPHIUses - Return true if the specified register has any PHI use. |
| 313 | static bool HasPHIUses(unsigned Reg, MachineRegisterInfo *RegInfo) { |
Evan Cheng | 45e94d6 | 2009-02-04 09:19:56 +0000 | [diff] [blame] | 314 | for (MachineRegisterInfo::use_iterator UI = RegInfo->use_begin(Reg), |
| 315 | UE = RegInfo->use_end(); UI != UE; ++UI) { |
| 316 | MachineInstr *UseMI = &*UI; |
Chris Lattner | 518bb53 | 2010-02-09 19:54:29 +0000 | [diff] [blame] | 317 | if (UseMI->isPHI()) |
Evan Cheng | af6949d | 2009-02-05 08:45:46 +0000 | [diff] [blame] | 318 | return true; |
Evan Cheng | 45e94d6 | 2009-02-04 09:19:56 +0000 | [diff] [blame] | 319 | } |
Evan Cheng | af6949d | 2009-02-05 08:45:46 +0000 | [diff] [blame] | 320 | return false; |
Evan Cheng | 45e94d6 | 2009-02-04 09:19:56 +0000 | [diff] [blame] | 321 | } |
| 322 | |
Evan Cheng | 87b75ba | 2009-11-20 19:55:37 +0000 | [diff] [blame] | 323 | /// isLoadFromConstantMemory - Return true if the given instruction is a |
| 324 | /// load from constant memory. Machine LICM will hoist these even if they are |
| 325 | /// not re-materializable. |
| 326 | bool MachineLICM::isLoadFromConstantMemory(MachineInstr *MI) { |
| 327 | if (!MI->getDesc().mayLoad()) return false; |
| 328 | if (!MI->hasOneMemOperand()) return false; |
| 329 | MachineMemOperand *MMO = *MI->memoperands_begin(); |
| 330 | if (MMO->isVolatile()) return false; |
| 331 | if (!MMO->getValue()) return false; |
| 332 | const PseudoSourceValue *PSV = dyn_cast<PseudoSourceValue>(MMO->getValue()); |
| 333 | if (PSV) { |
| 334 | MachineFunction &MF = *MI->getParent()->getParent(); |
| 335 | return PSV->isConstant(MF.getFrameInfo()); |
| 336 | } else { |
| 337 | return AA->pointsToConstantMemory(MMO->getValue()); |
| 338 | } |
| 339 | } |
| 340 | |
Evan Cheng | 45e94d6 | 2009-02-04 09:19:56 +0000 | [diff] [blame] | 341 | /// IsProfitableToHoist - Return true if it is potentially profitable to hoist |
| 342 | /// the given loop invariant. |
Evan Cheng | c26abd9 | 2009-11-20 23:31:34 +0000 | [diff] [blame] | 343 | bool MachineLICM::IsProfitableToHoist(MachineInstr &MI) { |
Chris Lattner | 518bb53 | 2010-02-09 19:54:29 +0000 | [diff] [blame] | 344 | if (MI.isImplicitDef()) |
Evan Cheng | efc7839 | 2009-02-27 00:02:22 +0000 | [diff] [blame] | 345 | return false; |
| 346 | |
Evan Cheng | 45e94d6 | 2009-02-04 09:19:56 +0000 | [diff] [blame] | 347 | // FIXME: For now, only hoist re-materilizable instructions. LICM will |
| 348 | // increase register pressure. We want to make sure it doesn't increase |
| 349 | // spilling. |
Evan Cheng | 87b75ba | 2009-11-20 19:55:37 +0000 | [diff] [blame] | 350 | // Also hoist loads from constant memory, e.g. load from stubs, GOT. Hoisting |
| 351 | // these tend to help performance in low register pressure situation. The |
| 352 | // trade off is it may cause spill in high pressure situation. It will end up |
| 353 | // adding a store in the loop preheader. But the reload is no more expensive. |
| 354 | // The side benefit is these loads are frequently CSE'ed. |
| 355 | if (!TII->isTriviallyReMaterializable(&MI, AA)) { |
Evan Cheng | c26abd9 | 2009-11-20 23:31:34 +0000 | [diff] [blame] | 356 | if (!isLoadFromConstantMemory(&MI)) |
Evan Cheng | 87b75ba | 2009-11-20 19:55:37 +0000 | [diff] [blame] | 357 | return false; |
Evan Cheng | 87b75ba | 2009-11-20 19:55:37 +0000 | [diff] [blame] | 358 | } |
Evan Cheng | 45e94d6 | 2009-02-04 09:19:56 +0000 | [diff] [blame] | 359 | |
Evan Cheng | af6949d | 2009-02-05 08:45:46 +0000 | [diff] [blame] | 360 | // If result(s) of this instruction is used by PHIs, then don't hoist it. |
| 361 | // The presence of joins makes it difficult for current register allocator |
| 362 | // implementation to perform remat. |
Evan Cheng | 45e94d6 | 2009-02-04 09:19:56 +0000 | [diff] [blame] | 363 | for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) { |
| 364 | const MachineOperand &MO = MI.getOperand(i); |
| 365 | if (!MO.isReg() || !MO.isDef()) |
| 366 | continue; |
Evan Cheng | af6949d | 2009-02-05 08:45:46 +0000 | [diff] [blame] | 367 | if (HasPHIUses(MO.getReg(), RegInfo)) |
| 368 | return false; |
Evan Cheng | 45e94d6 | 2009-02-04 09:19:56 +0000 | [diff] [blame] | 369 | } |
Evan Cheng | af6949d | 2009-02-05 08:45:46 +0000 | [diff] [blame] | 370 | |
| 371 | return true; |
| 372 | } |
| 373 | |
Dan Gohman | 5c95230 | 2009-10-29 17:47:20 +0000 | [diff] [blame] | 374 | MachineInstr *MachineLICM::ExtractHoistableLoad(MachineInstr *MI) { |
| 375 | // If not, we may be able to unfold a load and hoist that. |
| 376 | // First test whether the instruction is loading from an amenable |
| 377 | // memory location. |
Evan Cheng | 87b75ba | 2009-11-20 19:55:37 +0000 | [diff] [blame] | 378 | if (!isLoadFromConstantMemory(MI)) |
| 379 | return 0; |
| 380 | |
Dan Gohman | 5c95230 | 2009-10-29 17:47:20 +0000 | [diff] [blame] | 381 | // Next determine the register class for a temporary register. |
Dan Gohman | 0115e16 | 2009-10-30 22:18:41 +0000 | [diff] [blame] | 382 | unsigned LoadRegIndex; |
Dan Gohman | 5c95230 | 2009-10-29 17:47:20 +0000 | [diff] [blame] | 383 | unsigned NewOpc = |
| 384 | TII->getOpcodeAfterMemoryUnfold(MI->getOpcode(), |
| 385 | /*UnfoldLoad=*/true, |
Dan Gohman | 0115e16 | 2009-10-30 22:18:41 +0000 | [diff] [blame] | 386 | /*UnfoldStore=*/false, |
| 387 | &LoadRegIndex); |
Dan Gohman | 5c95230 | 2009-10-29 17:47:20 +0000 | [diff] [blame] | 388 | if (NewOpc == 0) return 0; |
| 389 | const TargetInstrDesc &TID = TII->get(NewOpc); |
| 390 | if (TID.getNumDefs() != 1) return 0; |
Dan Gohman | 0115e16 | 2009-10-30 22:18:41 +0000 | [diff] [blame] | 391 | const TargetRegisterClass *RC = TID.OpInfo[LoadRegIndex].getRegClass(TRI); |
Dan Gohman | 5c95230 | 2009-10-29 17:47:20 +0000 | [diff] [blame] | 392 | // Ok, we're unfolding. Create a temporary register and do the unfold. |
| 393 | unsigned Reg = RegInfo->createVirtualRegister(RC); |
Evan Cheng | 87b75ba | 2009-11-20 19:55:37 +0000 | [diff] [blame] | 394 | |
| 395 | MachineFunction &MF = *MI->getParent()->getParent(); |
Dan Gohman | 5c95230 | 2009-10-29 17:47:20 +0000 | [diff] [blame] | 396 | SmallVector<MachineInstr *, 2> NewMIs; |
| 397 | bool Success = |
| 398 | TII->unfoldMemoryOperand(MF, MI, Reg, |
| 399 | /*UnfoldLoad=*/true, /*UnfoldStore=*/false, |
| 400 | NewMIs); |
| 401 | (void)Success; |
| 402 | assert(Success && |
| 403 | "unfoldMemoryOperand failed when getOpcodeAfterMemoryUnfold " |
| 404 | "succeeded!"); |
| 405 | assert(NewMIs.size() == 2 && |
| 406 | "Unfolded a load into multiple instructions!"); |
| 407 | MachineBasicBlock *MBB = MI->getParent(); |
| 408 | MBB->insert(MI, NewMIs[0]); |
| 409 | MBB->insert(MI, NewMIs[1]); |
| 410 | // If unfolding produced a load that wasn't loop-invariant or profitable to |
| 411 | // hoist, discard the new instructions and bail. |
Evan Cheng | c26abd9 | 2009-11-20 23:31:34 +0000 | [diff] [blame] | 412 | if (!IsLoopInvariantInst(*NewMIs[0]) || !IsProfitableToHoist(*NewMIs[0])) { |
Dan Gohman | 5c95230 | 2009-10-29 17:47:20 +0000 | [diff] [blame] | 413 | NewMIs[0]->eraseFromParent(); |
| 414 | NewMIs[1]->eraseFromParent(); |
| 415 | return 0; |
| 416 | } |
| 417 | // Otherwise we successfully unfolded a load that we can hoist. |
| 418 | MI->eraseFromParent(); |
| 419 | return NewMIs[0]; |
| 420 | } |
| 421 | |
Evan Cheng | 777c6b7 | 2009-11-03 21:40:02 +0000 | [diff] [blame] | 422 | void MachineLICM::InitCSEMap(MachineBasicBlock *BB) { |
| 423 | for (MachineBasicBlock::iterator I = BB->begin(),E = BB->end(); I != E; ++I) { |
| 424 | const MachineInstr *MI = &*I; |
| 425 | // FIXME: For now, only hoist re-materilizable instructions. LICM will |
| 426 | // increase register pressure. We want to make sure it doesn't increase |
| 427 | // spilling. |
| 428 | if (TII->isTriviallyReMaterializable(MI, AA)) { |
| 429 | unsigned Opcode = MI->getOpcode(); |
| 430 | DenseMap<unsigned, std::vector<const MachineInstr*> >::iterator |
| 431 | CI = CSEMap.find(Opcode); |
| 432 | if (CI != CSEMap.end()) |
| 433 | CI->second.push_back(MI); |
| 434 | else { |
| 435 | std::vector<const MachineInstr*> CSEMIs; |
| 436 | CSEMIs.push_back(MI); |
| 437 | CSEMap.insert(std::make_pair(Opcode, CSEMIs)); |
| 438 | } |
| 439 | } |
| 440 | } |
| 441 | } |
| 442 | |
Evan Cheng | 78e5c11 | 2009-11-07 03:52:02 +0000 | [diff] [blame] | 443 | const MachineInstr* |
| 444 | MachineLICM::LookForDuplicate(const MachineInstr *MI, |
| 445 | std::vector<const MachineInstr*> &PrevMIs) { |
Evan Cheng | 9fb744e | 2009-11-05 00:51:13 +0000 | [diff] [blame] | 446 | for (unsigned i = 0, e = PrevMIs.size(); i != e; ++i) { |
| 447 | const MachineInstr *PrevMI = PrevMIs[i]; |
Evan Cheng | 78e5c11 | 2009-11-07 03:52:02 +0000 | [diff] [blame] | 448 | if (TII->isIdentical(MI, PrevMI, RegInfo)) |
Evan Cheng | 9fb744e | 2009-11-05 00:51:13 +0000 | [diff] [blame] | 449 | return PrevMI; |
| 450 | } |
| 451 | return 0; |
| 452 | } |
| 453 | |
| 454 | bool MachineLICM::EliminateCSE(MachineInstr *MI, |
| 455 | DenseMap<unsigned, std::vector<const MachineInstr*> >::iterator &CI) { |
Evan Cheng | 78e5c11 | 2009-11-07 03:52:02 +0000 | [diff] [blame] | 456 | if (CI == CSEMap.end()) |
| 457 | return false; |
| 458 | |
| 459 | if (const MachineInstr *Dup = LookForDuplicate(MI, CI->second)) { |
David Greene | 65a41eb | 2010-01-05 00:03:48 +0000 | [diff] [blame] | 460 | DEBUG(dbgs() << "CSEing " << *MI << " with " << *Dup); |
Evan Cheng | 78e5c11 | 2009-11-07 03:52:02 +0000 | [diff] [blame] | 461 | for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { |
| 462 | const MachineOperand &MO = MI->getOperand(i); |
| 463 | if (MO.isReg() && MO.isDef()) |
| 464 | RegInfo->replaceRegWith(MO.getReg(), Dup->getOperand(i).getReg()); |
Evan Cheng | 9fb744e | 2009-11-05 00:51:13 +0000 | [diff] [blame] | 465 | } |
Evan Cheng | 78e5c11 | 2009-11-07 03:52:02 +0000 | [diff] [blame] | 466 | MI->eraseFromParent(); |
| 467 | ++NumCSEed; |
| 468 | return true; |
Evan Cheng | 9fb744e | 2009-11-05 00:51:13 +0000 | [diff] [blame] | 469 | } |
| 470 | return false; |
| 471 | } |
| 472 | |
Bill Wendling | e4fc1cc | 2008-05-12 19:38:32 +0000 | [diff] [blame] | 473 | /// Hoist - When an instruction is found to use only loop invariant operands |
| 474 | /// that are safe to hoist, this instruction is called to do the dirty work. |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 475 | /// |
Dan Gohman | 589f1f5 | 2009-10-28 03:21:57 +0000 | [diff] [blame] | 476 | void MachineLICM::Hoist(MachineInstr *MI) { |
| 477 | // First check whether we should hoist this instruction. |
Evan Cheng | c26abd9 | 2009-11-20 23:31:34 +0000 | [diff] [blame] | 478 | if (!IsLoopInvariantInst(*MI) || !IsProfitableToHoist(*MI)) { |
Dan Gohman | 5c95230 | 2009-10-29 17:47:20 +0000 | [diff] [blame] | 479 | // If not, try unfolding a hoistable load. |
| 480 | MI = ExtractHoistableLoad(MI); |
| 481 | if (!MI) return; |
Dan Gohman | 589f1f5 | 2009-10-28 03:21:57 +0000 | [diff] [blame] | 482 | } |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 483 | |
Dan Gohman | c475c36 | 2009-01-15 22:01:38 +0000 | [diff] [blame] | 484 | // Now move the instructions to the predecessor, inserting it before any |
| 485 | // terminator instructions. |
| 486 | DEBUG({ |
David Greene | 65a41eb | 2010-01-05 00:03:48 +0000 | [diff] [blame] | 487 | dbgs() << "Hoisting " << *MI; |
Dan Gohman | c475c36 | 2009-01-15 22:01:38 +0000 | [diff] [blame] | 488 | if (CurPreheader->getBasicBlock()) |
David Greene | 65a41eb | 2010-01-05 00:03:48 +0000 | [diff] [blame] | 489 | dbgs() << " to MachineBasicBlock " |
Jakob Stoklund Olesen | 324da76 | 2009-11-20 01:17:03 +0000 | [diff] [blame] | 490 | << CurPreheader->getName(); |
Dan Gohman | 589f1f5 | 2009-10-28 03:21:57 +0000 | [diff] [blame] | 491 | if (MI->getParent()->getBasicBlock()) |
David Greene | 65a41eb | 2010-01-05 00:03:48 +0000 | [diff] [blame] | 492 | dbgs() << " from MachineBasicBlock " |
Jakob Stoklund Olesen | 324da76 | 2009-11-20 01:17:03 +0000 | [diff] [blame] | 493 | << MI->getParent()->getName(); |
David Greene | 65a41eb | 2010-01-05 00:03:48 +0000 | [diff] [blame] | 494 | dbgs() << "\n"; |
Dan Gohman | c475c36 | 2009-01-15 22:01:38 +0000 | [diff] [blame] | 495 | }); |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 496 | |
Evan Cheng | 777c6b7 | 2009-11-03 21:40:02 +0000 | [diff] [blame] | 497 | // If this is the first instruction being hoisted to the preheader, |
| 498 | // initialize the CSE map with potential common expressions. |
| 499 | InitCSEMap(CurPreheader); |
| 500 | |
Evan Cheng | af6949d | 2009-02-05 08:45:46 +0000 | [diff] [blame] | 501 | // Look for opportunity to CSE the hoisted instruction. |
Evan Cheng | 777c6b7 | 2009-11-03 21:40:02 +0000 | [diff] [blame] | 502 | unsigned Opcode = MI->getOpcode(); |
| 503 | DenseMap<unsigned, std::vector<const MachineInstr*> >::iterator |
| 504 | CI = CSEMap.find(Opcode); |
Evan Cheng | 9fb744e | 2009-11-05 00:51:13 +0000 | [diff] [blame] | 505 | if (!EliminateCSE(MI, CI)) { |
| 506 | // Otherwise, splice the instruction to the preheader. |
Evan Cheng | 777c6b7 | 2009-11-03 21:40:02 +0000 | [diff] [blame] | 507 | CurPreheader->splice(CurPreheader->getFirstTerminator(),MI->getParent(),MI); |
| 508 | |
Evan Cheng | af6949d | 2009-02-05 08:45:46 +0000 | [diff] [blame] | 509 | // Add to the CSE map. |
| 510 | if (CI != CSEMap.end()) |
Dan Gohman | 589f1f5 | 2009-10-28 03:21:57 +0000 | [diff] [blame] | 511 | CI->second.push_back(MI); |
Evan Cheng | af6949d | 2009-02-05 08:45:46 +0000 | [diff] [blame] | 512 | else { |
| 513 | std::vector<const MachineInstr*> CSEMIs; |
Dan Gohman | 589f1f5 | 2009-10-28 03:21:57 +0000 | [diff] [blame] | 514 | CSEMIs.push_back(MI); |
Evan Cheng | 777c6b7 | 2009-11-03 21:40:02 +0000 | [diff] [blame] | 515 | CSEMap.insert(std::make_pair(Opcode, CSEMIs)); |
Evan Cheng | af6949d | 2009-02-05 08:45:46 +0000 | [diff] [blame] | 516 | } |
| 517 | } |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 518 | |
Dan Gohman | c475c36 | 2009-01-15 22:01:38 +0000 | [diff] [blame] | 519 | ++NumHoisted; |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 520 | Changed = true; |
Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 521 | } |