blob: 5019e8eef19b45cf9e33d44891854a83b913a2ef [file] [log] [blame]
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +00001//===---- MachineCombiner.cpp - Instcombining on SSA form machine code ----===//
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// The machine combiner pass uses machine trace metrics to ensure the combined
11// instructions does not lengthen the critical path or the resource depth.
12//===----------------------------------------------------------------------===//
13#define DEBUG_TYPE "machine-combiner"
14
15#include "llvm/ADT/Statistic.h"
16#include "llvm/ADT/DenseMap.h"
17#include "llvm/CodeGen/MachineDominators.h"
18#include "llvm/CodeGen/MachineFunction.h"
19#include "llvm/CodeGen/MachineFunctionPass.h"
20#include "llvm/CodeGen/MachineInstrBuilder.h"
21#include "llvm/CodeGen/MachineLoopInfo.h"
22#include "llvm/CodeGen/MachineRegisterInfo.h"
23#include "llvm/CodeGen/MachineTraceMetrics.h"
24#include "llvm/CodeGen/Passes.h"
25#include "llvm/CodeGen/TargetSchedule.h"
26#include "llvm/Support/CommandLine.h"
27#include "llvm/Support/Debug.h"
28#include "llvm/Support/raw_ostream.h"
29#include "llvm/Target/TargetInstrInfo.h"
30#include "llvm/Target/TargetRegisterInfo.h"
31#include "llvm/Target/TargetSubtargetInfo.h"
32
33using namespace llvm;
34
35STATISTIC(NumInstCombined, "Number of machineinst combined");
36
37namespace {
38class MachineCombiner : public MachineFunctionPass {
39 const TargetInstrInfo *TII;
40 const TargetRegisterInfo *TRI;
Pete Cooper11759452014-09-02 17:43:54 +000041 MCSchedModel SchedModel;
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +000042 MachineRegisterInfo *MRI;
43 MachineTraceMetrics *Traces;
44 MachineTraceMetrics::Ensemble *MinInstr;
45
46 TargetSchedModel TSchedModel;
47
Sanjay Patelb1ca4e42015-01-27 22:26:56 +000048 /// True if optimizing for code size.
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +000049 bool OptSize;
50
51public:
52 static char ID;
53 MachineCombiner() : MachineFunctionPass(ID) {
54 initializeMachineCombinerPass(*PassRegistry::getPassRegistry());
55 }
56 void getAnalysisUsage(AnalysisUsage &AU) const override;
57 bool runOnMachineFunction(MachineFunction &MF) override;
58 const char *getPassName() const override { return "Machine InstCombiner"; }
59
60private:
61 bool doSubstitute(unsigned NewSize, unsigned OldSize);
62 bool combineInstructions(MachineBasicBlock *);
63 MachineInstr *getOperandDef(const MachineOperand &MO);
64 unsigned getDepth(SmallVectorImpl<MachineInstr *> &InsInstrs,
65 DenseMap<unsigned, unsigned> &InstrIdxForVirtReg,
66 MachineTraceMetrics::Trace BlockTrace);
67 unsigned getLatency(MachineInstr *Root, MachineInstr *NewRoot,
68 MachineTraceMetrics::Trace BlockTrace);
69 bool
70 preservesCriticalPathLen(MachineBasicBlock *MBB, MachineInstr *Root,
71 MachineTraceMetrics::Trace BlockTrace,
72 SmallVectorImpl<MachineInstr *> &InsInstrs,
73 DenseMap<unsigned, unsigned> &InstrIdxForVirtReg);
74 bool preservesResourceLen(MachineBasicBlock *MBB,
75 MachineTraceMetrics::Trace BlockTrace,
76 SmallVectorImpl<MachineInstr *> &InsInstrs,
77 SmallVectorImpl<MachineInstr *> &DelInstrs);
78 void instr2instrSC(SmallVectorImpl<MachineInstr *> &Instrs,
79 SmallVectorImpl<const MCSchedClassDesc *> &InstrsSC);
80};
Alexander Kornienko70bc5f12015-06-19 15:57:42 +000081} // namespace
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +000082
83char MachineCombiner::ID = 0;
84char &llvm::MachineCombinerID = MachineCombiner::ID;
85
86INITIALIZE_PASS_BEGIN(MachineCombiner, "machine-combiner",
87 "Machine InstCombiner", false, false)
88INITIALIZE_PASS_DEPENDENCY(MachineTraceMetrics)
89INITIALIZE_PASS_END(MachineCombiner, "machine-combiner", "Machine InstCombiner",
90 false, false)
91
92void MachineCombiner::getAnalysisUsage(AnalysisUsage &AU) const {
93 AU.setPreservesCFG();
94 AU.addPreserved<MachineDominatorTree>();
95 AU.addPreserved<MachineLoopInfo>();
96 AU.addRequired<MachineTraceMetrics>();
97 AU.addPreserved<MachineTraceMetrics>();
98 MachineFunctionPass::getAnalysisUsage(AU);
99}
100
101MachineInstr *MachineCombiner::getOperandDef(const MachineOperand &MO) {
102 MachineInstr *DefInstr = nullptr;
103 // We need a virtual register definition.
104 if (MO.isReg() && TargetRegisterInfo::isVirtualRegister(MO.getReg()))
105 DefInstr = MRI->getUniqueVRegDef(MO.getReg());
106 // PHI's have no depth etc.
107 if (DefInstr && DefInstr->isPHI())
108 DefInstr = nullptr;
109 return DefInstr;
110}
111
Sanjay Patelb1ca4e42015-01-27 22:26:56 +0000112/// Computes depth of instructions in vector \InsInstr.
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000113///
114/// \param InsInstrs is a vector of machine instructions
115/// \param InstrIdxForVirtReg is a dense map of virtual register to index
116/// of defining machine instruction in \p InsInstrs
117/// \param BlockTrace is a trace of machine instructions
118///
119/// \returns Depth of last instruction in \InsInstrs ("NewRoot")
120unsigned
121MachineCombiner::getDepth(SmallVectorImpl<MachineInstr *> &InsInstrs,
122 DenseMap<unsigned, unsigned> &InstrIdxForVirtReg,
123 MachineTraceMetrics::Trace BlockTrace) {
124
125 SmallVector<unsigned, 16> InstrDepth;
126 assert(TSchedModel.hasInstrSchedModel() && "Missing machine model\n");
127
Sanjay Patel6b280772015-01-27 22:16:52 +0000128 // For each instruction in the new sequence compute the depth based on the
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000129 // operands. Use the trace information when possible. For new operands which
130 // are tracked in the InstrIdxForVirtReg map depth is looked up in InstrDepth
131 for (auto *InstrPtr : InsInstrs) { // for each Use
132 unsigned IDepth = 0;
133 DEBUG(dbgs() << "NEW INSTR "; InstrPtr->dump(); dbgs() << "\n";);
Sanjay Patelf69f4e42015-05-21 17:43:26 +0000134 for (const MachineOperand &MO : InstrPtr->operands()) {
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000135 // Check for virtual register operand.
136 if (!(MO.isReg() && TargetRegisterInfo::isVirtualRegister(MO.getReg())))
137 continue;
138 if (!MO.isUse())
139 continue;
140 unsigned DepthOp = 0;
141 unsigned LatencyOp = 0;
142 DenseMap<unsigned, unsigned>::iterator II =
143 InstrIdxForVirtReg.find(MO.getReg());
144 if (II != InstrIdxForVirtReg.end()) {
145 // Operand is new virtual register not in trace
Saleem Abdulrasoolbefa2152014-08-03 23:00:38 +0000146 assert(II->second < InstrDepth.size() && "Bad Index");
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000147 MachineInstr *DefInstr = InsInstrs[II->second];
148 assert(DefInstr &&
149 "There must be a definition for a new virtual register");
150 DepthOp = InstrDepth[II->second];
151 LatencyOp = TSchedModel.computeOperandLatency(
152 DefInstr, DefInstr->findRegisterDefOperandIdx(MO.getReg()),
153 InstrPtr, InstrPtr->findRegisterUseOperandIdx(MO.getReg()));
154 } else {
155 MachineInstr *DefInstr = getOperandDef(MO);
156 if (DefInstr) {
157 DepthOp = BlockTrace.getInstrCycles(DefInstr).Depth;
158 LatencyOp = TSchedModel.computeOperandLatency(
159 DefInstr, DefInstr->findRegisterDefOperandIdx(MO.getReg()),
160 InstrPtr, InstrPtr->findRegisterUseOperandIdx(MO.getReg()));
161 }
162 }
163 IDepth = std::max(IDepth, DepthOp + LatencyOp);
164 }
165 InstrDepth.push_back(IDepth);
166 }
167 unsigned NewRootIdx = InsInstrs.size() - 1;
168 return InstrDepth[NewRootIdx];
169}
170
Sanjay Patelb1ca4e42015-01-27 22:26:56 +0000171/// Computes instruction latency as max of latency of defined operands.
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000172///
173/// \param Root is a machine instruction that could be replaced by NewRoot.
174/// It is used to compute a more accurate latency information for NewRoot in
175/// case there is a dependent instruction in the same trace (\p BlockTrace)
176/// \param NewRoot is the instruction for which the latency is computed
177/// \param BlockTrace is a trace of machine instructions
178///
179/// \returns Latency of \p NewRoot
180unsigned MachineCombiner::getLatency(MachineInstr *Root, MachineInstr *NewRoot,
181 MachineTraceMetrics::Trace BlockTrace) {
182
183 assert(TSchedModel.hasInstrSchedModel() && "Missing machine model\n");
184
185 // Check each definition in NewRoot and compute the latency
186 unsigned NewRootLatency = 0;
187
Sanjay Patelf69f4e42015-05-21 17:43:26 +0000188 for (const MachineOperand &MO : NewRoot->operands()) {
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000189 // Check for virtual register operand.
190 if (!(MO.isReg() && TargetRegisterInfo::isVirtualRegister(MO.getReg())))
191 continue;
192 if (!MO.isDef())
193 continue;
194 // Get the first instruction that uses MO
195 MachineRegisterInfo::reg_iterator RI = MRI->reg_begin(MO.getReg());
196 RI++;
197 MachineInstr *UseMO = RI->getParent();
198 unsigned LatencyOp = 0;
199 if (UseMO && BlockTrace.isDepInTrace(Root, UseMO)) {
200 LatencyOp = TSchedModel.computeOperandLatency(
201 NewRoot, NewRoot->findRegisterDefOperandIdx(MO.getReg()), UseMO,
202 UseMO->findRegisterUseOperandIdx(MO.getReg()));
203 } else {
204 LatencyOp = TSchedModel.computeInstrLatency(NewRoot->getOpcode());
205 }
206 NewRootLatency = std::max(NewRootLatency, LatencyOp);
207 }
208 return NewRootLatency;
209}
210
Sanjay Patelb1ca4e42015-01-27 22:26:56 +0000211/// True when the new instruction sequence does not
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000212/// lengthen the critical path. The DAGCombine code sequence ends in MI
213/// (Machine Instruction) Root. The new code sequence ends in MI NewRoot. A
214/// necessary condition for the new sequence to replace the old sequence is that
Sanjay Patel6b280772015-01-27 22:16:52 +0000215/// it cannot lengthen the critical path. This is decided by the formula
216/// (NewRootDepth + NewRootLatency) <= (RootDepth + RootLatency + RootSlack)).
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000217/// The slack is the number of cycles Root can be delayed before the critical
218/// patch becomes longer.
219bool MachineCombiner::preservesCriticalPathLen(
220 MachineBasicBlock *MBB, MachineInstr *Root,
221 MachineTraceMetrics::Trace BlockTrace,
222 SmallVectorImpl<MachineInstr *> &InsInstrs,
223 DenseMap<unsigned, unsigned> &InstrIdxForVirtReg) {
224
225 assert(TSchedModel.hasInstrSchedModel() && "Missing machine model\n");
Sanjay Patelccb8d5c2015-06-10 19:52:58 +0000226 // NewRoot is the last instruction in the \p InsInstrs vector.
227 // Get depth and latency of NewRoot.
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000228 unsigned NewRootIdx = InsInstrs.size() - 1;
229 MachineInstr *NewRoot = InsInstrs[NewRootIdx];
230 unsigned NewRootDepth = getDepth(InsInstrs, InstrIdxForVirtReg, BlockTrace);
231 unsigned NewRootLatency = getLatency(Root, NewRoot, BlockTrace);
232
Sanjay Patelccb8d5c2015-06-10 19:52:58 +0000233 // Get depth, latency and slack of Root.
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000234 unsigned RootDepth = BlockTrace.getInstrCycles(Root).Depth;
235 unsigned RootLatency = TSchedModel.computeInstrLatency(Root);
236 unsigned RootSlack = BlockTrace.getInstrSlack(Root);
237
238 DEBUG(dbgs() << "DEPENDENCE DATA FOR " << Root << "\n";
239 dbgs() << " NewRootDepth: " << NewRootDepth
240 << " NewRootLatency: " << NewRootLatency << "\n";
241 dbgs() << " RootDepth: " << RootDepth << " RootLatency: " << RootLatency
242 << " RootSlack: " << RootSlack << "\n";
243 dbgs() << " NewRootDepth + NewRootLatency "
244 << NewRootDepth + NewRootLatency << "\n";
245 dbgs() << " RootDepth + RootLatency + RootSlack "
246 << RootDepth + RootLatency + RootSlack << "\n";);
247
Sanjay Patela32fadd2015-06-10 17:08:12 +0000248 /// True when the new sequence does not lengthen the critical path.
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000249 return ((NewRootDepth + NewRootLatency) <=
250 (RootDepth + RootLatency + RootSlack));
251}
252
253/// helper routine to convert instructions into SC
254void MachineCombiner::instr2instrSC(
255 SmallVectorImpl<MachineInstr *> &Instrs,
256 SmallVectorImpl<const MCSchedClassDesc *> &InstrsSC) {
257 for (auto *InstrPtr : Instrs) {
258 unsigned Opc = InstrPtr->getOpcode();
259 unsigned Idx = TII->get(Opc).getSchedClass();
Pete Cooper11759452014-09-02 17:43:54 +0000260 const MCSchedClassDesc *SC = SchedModel.getSchedClassDesc(Idx);
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000261 InstrsSC.push_back(SC);
262 }
263}
Sanjay Patelb1ca4e42015-01-27 22:26:56 +0000264/// True when the new instructions do not increase resource length
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000265bool MachineCombiner::preservesResourceLen(
266 MachineBasicBlock *MBB, MachineTraceMetrics::Trace BlockTrace,
267 SmallVectorImpl<MachineInstr *> &InsInstrs,
268 SmallVectorImpl<MachineInstr *> &DelInstrs) {
269
270 // Compute current resource length
271
Gerolf Hoflehner97c383b2014-08-07 21:40:58 +0000272 //ArrayRef<const MachineBasicBlock *> MBBarr(MBB);
273 SmallVector <const MachineBasicBlock *, 1> MBBarr;
274 MBBarr.push_back(MBB);
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000275 unsigned ResLenBeforeCombine = BlockTrace.getResourceLength(MBBarr);
276
277 // Deal with SC rather than Instructions.
278 SmallVector<const MCSchedClassDesc *, 16> InsInstrsSC;
279 SmallVector<const MCSchedClassDesc *, 16> DelInstrsSC;
280
281 instr2instrSC(InsInstrs, InsInstrsSC);
282 instr2instrSC(DelInstrs, DelInstrsSC);
283
284 ArrayRef<const MCSchedClassDesc *> MSCInsArr = makeArrayRef(InsInstrsSC);
285 ArrayRef<const MCSchedClassDesc *> MSCDelArr = makeArrayRef(DelInstrsSC);
286
Sanjay Patelccb8d5c2015-06-10 19:52:58 +0000287 // Compute new resource length.
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000288 unsigned ResLenAfterCombine =
289 BlockTrace.getResourceLength(MBBarr, MSCInsArr, MSCDelArr);
290
291 DEBUG(dbgs() << "RESOURCE DATA: \n";
292 dbgs() << " resource len before: " << ResLenBeforeCombine
293 << " after: " << ResLenAfterCombine << "\n";);
294
295 return ResLenAfterCombine <= ResLenBeforeCombine;
296}
297
298/// \returns true when new instruction sequence should be generated
Sanjay Patel6b280772015-01-27 22:16:52 +0000299/// independent if it lengthens critical path or not
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000300bool MachineCombiner::doSubstitute(unsigned NewSize, unsigned OldSize) {
301 if (OptSize && (NewSize < OldSize))
302 return true;
303 if (!TSchedModel.hasInstrSchedModel())
304 return true;
305 return false;
306}
307
Sanjay Patelb1ca4e42015-01-27 22:26:56 +0000308/// Substitute a slow code sequence with a faster one by
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000309/// evaluating instruction combining pattern.
310/// The prototype of such a pattern is MUl + ADD -> MADD. Performs instruction
311/// combining based on machine trace metrics. Only combine a sequence of
312/// instructions when this neither lengthens the critical path nor increases
313/// resource pressure. When optimizing for codesize always combine when the new
314/// sequence is shorter.
315bool MachineCombiner::combineInstructions(MachineBasicBlock *MBB) {
316 bool Changed = false;
317 DEBUG(dbgs() << "Combining MBB " << MBB->getName() << "\n");
318
319 auto BlockIter = MBB->begin();
320
321 while (BlockIter != MBB->end()) {
322 auto &MI = *BlockIter++;
323
324 DEBUG(dbgs() << "INSTR "; MI.dump(); dbgs() << "\n";);
Sanjay Patelcfe03932015-06-19 23:21:42 +0000325 SmallVector<MachineCombinerPattern::MC_PATTERN, 16> Patterns;
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000326 // The motivating example is:
327 //
328 // MUL Other MUL_op1 MUL_op2 Other
329 // \ / \ | /
330 // ADD/SUB => MADD/MSUB
331 // (=Root) (=NewRoot)
332
333 // The DAGCombine code always replaced MUL + ADD/SUB by MADD. While this is
334 // usually beneficial for code size it unfortunately can hurt performance
335 // when the ADD is on the critical path, but the MUL is not. With the
336 // substitution the MUL becomes part of the critical path (in form of the
337 // MADD) and can lengthen it on architectures where the MADD latency is
338 // longer than the ADD latency.
339 //
340 // For each instruction we check if it can be the root of a combiner
341 // pattern. Then for each pattern the new code sequence in form of MI is
342 // generated and evaluated. When the efficiency criteria (don't lengthen
343 // critical path, don't use more resources) is met the new sequence gets
344 // hooked up into the basic block before the old sequence is removed.
345 //
346 // The algorithm does not try to evaluate all patterns and pick the best.
347 // This is only an artificial restriction though. In practice there is
Sanjay Patelcfe03932015-06-19 23:21:42 +0000348 // mostly one pattern, and getMachineCombinerPatterns() can order patterns
349 // based on an internal cost heuristic.
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000350
Sanjay Patelcfe03932015-06-19 23:21:42 +0000351 if (TII->getMachineCombinerPatterns(MI, Patterns)) {
352 for (auto P : Patterns) {
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000353 SmallVector<MachineInstr *, 16> InsInstrs;
354 SmallVector<MachineInstr *, 16> DelInstrs;
355 DenseMap<unsigned, unsigned> InstrIdxForVirtReg;
356 if (!MinInstr)
357 MinInstr = Traces->getEnsemble(MachineTraceMetrics::TS_MinInstrCount);
358 MachineTraceMetrics::Trace BlockTrace = MinInstr->getTrace(MBB);
359 Traces->verifyAnalysis();
360 TII->genAlternativeCodeSequence(MI, P, InsInstrs, DelInstrs,
361 InstrIdxForVirtReg);
362 // Found pattern, but did not generate alternative sequence.
363 // This can happen e.g. when an immediate could not be materialized
364 // in a single instruction.
365 if (!InsInstrs.size())
366 continue;
367 // Substitute when we optimize for codesize and the new sequence has
368 // fewer instructions OR
Sanjay Patelf9114842015-05-21 21:29:13 +0000369 // the new sequence neither lengthens the critical path nor increases
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000370 // resource pressure.
371 if (doSubstitute(InsInstrs.size(), DelInstrs.size()) ||
372 (preservesCriticalPathLen(MBB, &MI, BlockTrace, InsInstrs,
373 InstrIdxForVirtReg) &&
374 preservesResourceLen(MBB, BlockTrace, InsInstrs, DelInstrs))) {
375 for (auto *InstrPtr : InsInstrs)
Sanjay Patel85924e52015-06-13 15:06:33 +0000376 MBB->insert((MachineBasicBlock::iterator) &MI, InstrPtr);
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000377 for (auto *InstrPtr : DelInstrs)
Gerolf Hoflehnerfe2c11f2014-08-13 22:07:36 +0000378 InstrPtr->eraseFromParentAndMarkDBGValuesForRemoval();
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000379
380 Changed = true;
381 ++NumInstCombined;
382
383 Traces->invalidate(MBB);
384 Traces->verifyAnalysis();
Sanjay Patelccb8d5c2015-06-10 19:52:58 +0000385 // Eagerly stop after the first pattern fires.
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000386 break;
387 } else {
388 // Cleanup instructions of the alternative code sequence. There is no
389 // use for them.
Sanjay Patel57149982015-06-13 15:33:15 +0000390 MachineFunction *MF = MBB->getParent();
391 for (auto *InstrPtr : InsInstrs)
Sanjay Patel85924e52015-06-13 15:06:33 +0000392 MF->DeleteMachineInstr(InstrPtr);
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000393 }
394 InstrIdxForVirtReg.clear();
395 }
396 }
397 }
398
399 return Changed;
400}
401
402bool MachineCombiner::runOnMachineFunction(MachineFunction &MF) {
Eric Christopher3d4276f2015-01-27 07:31:29 +0000403 const TargetSubtargetInfo &STI = MF.getSubtarget();
Eric Christopherd9134482014-08-04 21:25:23 +0000404 TII = STI.getInstrInfo();
405 TRI = STI.getRegisterInfo();
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000406 SchedModel = STI.getSchedModel();
Pete Cooper11759452014-09-02 17:43:54 +0000407 TSchedModel.init(SchedModel, &STI, TII);
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000408 MRI = &MF.getRegInfo();
409 Traces = &getAnalysis<MachineTraceMetrics>();
410 MinInstr = 0;
411
Duncan P. N. Exon Smith70eb9c52015-02-14 01:44:41 +0000412 OptSize = MF.getFunction()->hasFnAttribute(Attribute::OptimizeForSize);
Gerolf Hoflehner5e1207e2014-08-03 21:35:39 +0000413
414 DEBUG(dbgs() << getPassName() << ": " << MF.getName() << '\n');
415 if (!TII->useMachineCombiner()) {
416 DEBUG(dbgs() << " Skipping pass: Target does not support machine combiner\n");
417 return false;
418 }
419
420 bool Changed = false;
421
422 // Try to combine instructions.
423 for (auto &MBB : MF)
424 Changed |= combineInstructions(&MBB);
425
426 return Changed;
427}