blob: dc8f6d5f0bc2b668f184f6440085246b16e7256b [file] [log] [blame]
Preston Gurd8b7ab4b2013-04-25 20:29:37 +00001//===-- X86FixupLEAs.cpp - use or replace LEA instructions -----------===//
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//
Sanjay Patel63604412014-07-16 20:18:49 +000010// This file defines the pass that finds instructions that can be
11// re-written as LEA instructions in order to reduce pipeline delays.
Michael Kuperstein12982a82015-11-11 11:44:31 +000012// When optimizing for size it replaces suitable LEAs with INC or DEC.
Preston Gurd8b7ab4b2013-04-25 20:29:37 +000013//
14//===----------------------------------------------------------------------===//
15
Preston Gurd8b7ab4b2013-04-25 20:29:37 +000016#include "X86.h"
17#include "X86InstrInfo.h"
18#include "X86Subtarget.h"
19#include "llvm/ADT/Statistic.h"
20#include "llvm/CodeGen/LiveVariables.h"
21#include "llvm/CodeGen/MachineFunctionPass.h"
22#include "llvm/CodeGen/MachineInstrBuilder.h"
23#include "llvm/CodeGen/MachineRegisterInfo.h"
24#include "llvm/CodeGen/Passes.h"
25#include "llvm/Support/Debug.h"
26#include "llvm/Support/raw_ostream.h"
27#include "llvm/Target/TargetInstrInfo.h"
28using namespace llvm;
29
Chandler Carruth84e68b22014-04-22 02:41:26 +000030#define DEBUG_TYPE "x86-fixup-LEAs"
31
Preston Gurd8b7ab4b2013-04-25 20:29:37 +000032STATISTIC(NumLEAs, "Number of LEA instructions created");
33
34namespace {
Eric Christopher31b81ce2014-06-03 21:01:35 +000035class FixupLEAPass : public MachineFunctionPass {
36 enum RegUsageState { RU_NotUsed, RU_Write, RU_Read };
37 static char ID;
38 /// \brief Loop over all of the instructions in the basic block
39 /// replacing applicable instructions with LEA instructions,
40 /// where appropriate.
41 bool processBasicBlock(MachineFunction &MF, MachineFunction::iterator MFI);
Preston Gurd8b7ab4b2013-04-25 20:29:37 +000042
Sanjay Patel63604412014-07-16 20:18:49 +000043 const char *getPassName() const override { return "X86 LEA Fixup"; }
Preston Gurd128920d2013-04-25 21:31:33 +000044
Eric Christopher31b81ce2014-06-03 21:01:35 +000045 /// \brief Given a machine register, look for the instruction
46 /// which writes it in the current basic block. If found,
47 /// try to replace it with an equivalent LEA instruction.
Eric Christopher572e03a2015-06-19 01:53:21 +000048 /// If replacement succeeds, then also process the newly created
Eric Christopher31b81ce2014-06-03 21:01:35 +000049 /// instruction.
50 void seekLEAFixup(MachineOperand &p, MachineBasicBlock::iterator &I,
51 MachineFunction::iterator MFI);
Preston Gurd128920d2013-04-25 21:31:33 +000052
Eric Christopher31b81ce2014-06-03 21:01:35 +000053 /// \brief Given a memory access or LEA instruction
54 /// whose address mode uses a base and/or index register, look for
55 /// an opportunity to replace the instruction which sets the base or index
56 /// register with an equivalent LEA instruction.
57 void processInstruction(MachineBasicBlock::iterator &I,
58 MachineFunction::iterator MFI);
Preston Gurd128920d2013-04-25 21:31:33 +000059
Eric Christopher31b81ce2014-06-03 21:01:35 +000060 /// \brief Given a LEA instruction which is unprofitable
61 /// on Silvermont try to replace it with an equivalent ADD instruction
62 void processInstructionForSLM(MachineBasicBlock::iterator &I,
63 MachineFunction::iterator MFI);
Alexey Volkov6226de62014-05-20 08:55:50 +000064
Michael Kuperstein12982a82015-11-11 11:44:31 +000065 /// \brief Look for LEAs that add 1 to reg or subtract 1 from reg
66 /// and convert them to INC or DEC respectively.
67 bool fixupIncDec(MachineBasicBlock::iterator &I,
68 MachineFunction::iterator MFI) const;
69
Eric Christopher31b81ce2014-06-03 21:01:35 +000070 /// \brief Determine if an instruction references a machine register
71 /// and, if so, whether it reads or writes the register.
72 RegUsageState usesRegister(MachineOperand &p, MachineBasicBlock::iterator I);
Preston Gurd128920d2013-04-25 21:31:33 +000073
Eric Christopher31b81ce2014-06-03 21:01:35 +000074 /// \brief Step backwards through a basic block, looking
75 /// for an instruction which writes a register within
76 /// a maximum of INSTR_DISTANCE_THRESHOLD instruction latency cycles.
77 MachineBasicBlock::iterator searchBackwards(MachineOperand &p,
78 MachineBasicBlock::iterator &I,
79 MachineFunction::iterator MFI);
Preston Gurd128920d2013-04-25 21:31:33 +000080
Eric Christopher31b81ce2014-06-03 21:01:35 +000081 /// \brief if an instruction can be converted to an
82 /// equivalent LEA, insert the new instruction into the basic block
83 /// and return a pointer to it. Otherwise, return zero.
84 MachineInstr *postRAConvertToLEA(MachineFunction::iterator &MFI,
85 MachineBasicBlock::iterator &MBBI) const;
Preston Gurd8b7ab4b2013-04-25 20:29:37 +000086
Eric Christopher31b81ce2014-06-03 21:01:35 +000087public:
88 FixupLEAPass() : MachineFunctionPass(ID) {}
Preston Gurd8b7ab4b2013-04-25 20:29:37 +000089
Eric Christopher31b81ce2014-06-03 21:01:35 +000090 /// \brief Loop over all of the basic blocks,
91 /// replacing instructions by equivalent LEA instructions
92 /// if needed and when possible.
93 bool runOnMachineFunction(MachineFunction &MF) override;
Preston Gurd8b7ab4b2013-04-25 20:29:37 +000094
Derek Schuff1dbf7a52016-04-04 17:09:25 +000095 // This pass runs after regalloc and doesn't support VReg operands.
96 MachineFunctionProperties getRequiredProperties() const override {
97 return MachineFunctionProperties().set(
98 MachineFunctionProperties::Property::AllVRegsAllocated);
99 }
100
Eric Christopher31b81ce2014-06-03 21:01:35 +0000101private:
102 MachineFunction *MF;
Eric Christopher31b81ce2014-06-03 21:01:35 +0000103 const X86InstrInfo *TII; // Machine instruction info.
Michael Kuperstein12982a82015-11-11 11:44:31 +0000104 bool OptIncDec;
105 bool OptLEA;
Eric Christopher31b81ce2014-06-03 21:01:35 +0000106};
107char FixupLEAPass::ID = 0;
Alexander Kornienkof00654e2015-06-23 09:49:53 +0000108}
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000109
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000110MachineInstr *
111FixupLEAPass::postRAConvertToLEA(MachineFunction::iterator &MFI,
Preston Gurd128920d2013-04-25 21:31:33 +0000112 MachineBasicBlock::iterator &MBBI) const {
Eric Christopher31b81ce2014-06-03 21:01:35 +0000113 MachineInstr *MI = MBBI;
114 MachineInstr *NewMI;
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000115 switch (MI->getOpcode()) {
Alexey Volkov6226de62014-05-20 08:55:50 +0000116 case X86::MOV32rr:
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000117 case X86::MOV64rr: {
Eric Christopher31b81ce2014-06-03 21:01:35 +0000118 const MachineOperand &Src = MI->getOperand(1);
119 const MachineOperand &Dest = MI->getOperand(0);
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000120 NewMI = BuildMI(*MF, MI->getDebugLoc(),
Eric Christopher31b81ce2014-06-03 21:01:35 +0000121 TII->get(MI->getOpcode() == X86::MOV32rr ? X86::LEA32r
122 : X86::LEA64r))
123 .addOperand(Dest)
124 .addOperand(Src)
125 .addImm(1)
126 .addReg(0)
127 .addImm(0)
128 .addReg(0);
129 MFI->insert(MBBI, NewMI); // Insert the new inst
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000130 return NewMI;
131 }
132 case X86::ADD64ri32:
133 case X86::ADD64ri8:
134 case X86::ADD64ri32_DB:
135 case X86::ADD64ri8_DB:
136 case X86::ADD32ri:
137 case X86::ADD32ri8:
138 case X86::ADD32ri_DB:
139 case X86::ADD32ri8_DB:
140 case X86::ADD16ri:
141 case X86::ADD16ri8:
142 case X86::ADD16ri_DB:
143 case X86::ADD16ri8_DB:
144 if (!MI->getOperand(2).isImm()) {
145 // convertToThreeAddress will call getImm()
146 // which requires isImm() to be true
Craig Topper062a2ba2014-04-25 05:30:21 +0000147 return nullptr;
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000148 }
Preston Gurdf03a6e72013-09-30 23:51:22 +0000149 break;
Preston Gurdf0b62882013-09-30 23:18:42 +0000150 case X86::ADD16rr:
151 case X86::ADD16rr_DB:
152 if (MI->getOperand(1).getReg() != MI->getOperand(2).getReg()) {
153 // if src1 != src2, then convertToThreeAddress will
154 // need to create a Virtual register, which we cannot do
155 // after register allocation.
Craig Topper062a2ba2014-04-25 05:30:21 +0000156 return nullptr;
Preston Gurdf0b62882013-09-30 23:18:42 +0000157 }
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000158 }
Craig Topper062a2ba2014-04-25 05:30:21 +0000159 return TII->convertToThreeAddress(MFI, MBBI, nullptr);
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000160}
161
Eric Christopher31b81ce2014-06-03 21:01:35 +0000162FunctionPass *llvm::createX86FixupLEAs() { return new FixupLEAPass(); }
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000163
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000164bool FixupLEAPass::runOnMachineFunction(MachineFunction &Func) {
Eric Christopherdd240fd2014-06-03 21:01:39 +0000165 MF = &Func;
Eric Christopher4369c9b2015-02-20 08:01:52 +0000166 const X86Subtarget &ST = Func.getSubtarget<X86Subtarget>();
Michael Kuperstein12982a82015-11-11 11:44:31 +0000167 OptIncDec = !ST.slowIncDec() || Func.getFunction()->optForMinSize();
168 OptLEA = ST.LEAusesAG() || ST.slowLEA();
169
170 if (!OptLEA && !OptIncDec)
Eric Christopher0d5c99e2014-05-22 01:46:02 +0000171 return false;
172
Eric Christopherd361ff82015-02-05 19:27:01 +0000173 TII = ST.getInstrInfo();
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000174
175 DEBUG(dbgs() << "Start X86FixupLEAs\n";);
176 // Process all basic blocks.
177 for (MachineFunction::iterator I = Func.begin(), E = Func.end(); I != E; ++I)
178 processBasicBlock(Func, I);
179 DEBUG(dbgs() << "End X86FixupLEAs\n";);
180
181 return true;
182}
183
Eric Christopher31b81ce2014-06-03 21:01:35 +0000184FixupLEAPass::RegUsageState
185FixupLEAPass::usesRegister(MachineOperand &p, MachineBasicBlock::iterator I) {
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000186 RegUsageState RegUsage = RU_NotUsed;
Eric Christopher31b81ce2014-06-03 21:01:35 +0000187 MachineInstr *MI = I;
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000188
189 for (unsigned int i = 0; i < MI->getNumOperands(); ++i) {
Eric Christopher31b81ce2014-06-03 21:01:35 +0000190 MachineOperand &opnd = MI->getOperand(i);
191 if (opnd.isReg() && opnd.getReg() == p.getReg()) {
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000192 if (opnd.isDef())
193 return RU_Write;
194 RegUsage = RU_Read;
195 }
196 }
197 return RegUsage;
198}
199
200/// getPreviousInstr - Given a reference to an instruction in a basic
201/// block, return a reference to the previous instruction in the block,
202/// wrapping around to the last instruction of the block if the block
203/// branches to itself.
Eric Christopher31b81ce2014-06-03 21:01:35 +0000204static inline bool getPreviousInstr(MachineBasicBlock::iterator &I,
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000205 MachineFunction::iterator MFI) {
206 if (I == MFI->begin()) {
Duncan P. N. Exon Smithd77de642015-10-19 21:48:29 +0000207 if (MFI->isPredecessor(&*MFI)) {
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000208 I = --MFI->end();
209 return true;
Eric Christopher31b81ce2014-06-03 21:01:35 +0000210 } else
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000211 return false;
212 }
213 --I;
214 return true;
215}
216
Eric Christopher31b81ce2014-06-03 21:01:35 +0000217MachineBasicBlock::iterator
218FixupLEAPass::searchBackwards(MachineOperand &p, MachineBasicBlock::iterator &I,
219 MachineFunction::iterator MFI) {
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000220 int InstrDistance = 1;
221 MachineBasicBlock::iterator CurInst;
222 static const int INSTR_DISTANCE_THRESHOLD = 5;
223
224 CurInst = I;
225 bool Found;
226 Found = getPreviousInstr(CurInst, MFI);
Eric Christopher31b81ce2014-06-03 21:01:35 +0000227 while (Found && I != CurInst) {
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000228 if (CurInst->isCall() || CurInst->isInlineAsm())
229 break;
230 if (InstrDistance > INSTR_DISTANCE_THRESHOLD)
231 break; // too far back to make a difference
Eric Christopher31b81ce2014-06-03 21:01:35 +0000232 if (usesRegister(p, CurInst) == RU_Write) {
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000233 return CurInst;
234 }
Eric Christopherd9134482014-08-04 21:25:23 +0000235 InstrDistance += TII->getInstrLatency(
Eric Christopherd361ff82015-02-05 19:27:01 +0000236 MF->getSubtarget().getInstrItineraryData(), CurInst);
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000237 Found = getPreviousInstr(CurInst, MFI);
238 }
Craig Topper062a2ba2014-04-25 05:30:21 +0000239 return nullptr;
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000240}
241
Michael Kuperstein12982a82015-11-11 11:44:31 +0000242static inline bool isLEA(const int opcode) {
243 return opcode == X86::LEA16r || opcode == X86::LEA32r ||
244 opcode == X86::LEA64r || opcode == X86::LEA64_32r;
245}
246
247/// isLEASimpleIncOrDec - Does this LEA have one these forms:
248/// lea %reg, 1(%reg)
249/// lea %reg, -1(%reg)
250static inline bool isLEASimpleIncOrDec(MachineInstr *LEA) {
251 unsigned SrcReg = LEA->getOperand(1 + X86::AddrBaseReg).getReg();
252 unsigned DstReg = LEA->getOperand(0).getReg();
253 unsigned AddrDispOp = 1 + X86::AddrDisp;
254 return SrcReg == DstReg &&
255 LEA->getOperand(1 + X86::AddrIndexReg).getReg() == 0 &&
256 LEA->getOperand(1 + X86::AddrSegmentReg).getReg() == 0 &&
257 LEA->getOperand(AddrDispOp).isImm() &&
258 (LEA->getOperand(AddrDispOp).getImm() == 1 ||
259 LEA->getOperand(AddrDispOp).getImm() == -1);
260}
261
262bool FixupLEAPass::fixupIncDec(MachineBasicBlock::iterator &I,
263 MachineFunction::iterator MFI) const {
264 MachineInstr *MI = I;
265 int Opcode = MI->getOpcode();
266 if (!isLEA(Opcode))
267 return false;
268
269 if (isLEASimpleIncOrDec(MI) && TII->isSafeToClobberEFLAGS(*MFI, I)) {
270 int NewOpcode;
271 bool isINC = MI->getOperand(4).getImm() == 1;
272 switch (Opcode) {
273 case X86::LEA16r:
274 NewOpcode = isINC ? X86::INC16r : X86::DEC16r;
275 break;
276 case X86::LEA32r:
277 case X86::LEA64_32r:
278 NewOpcode = isINC ? X86::INC32r : X86::DEC32r;
279 break;
280 case X86::LEA64r:
281 NewOpcode = isINC ? X86::INC64r : X86::DEC64r;
282 break;
283 }
284
285 MachineInstr *NewMI =
286 BuildMI(*MFI, I, MI->getDebugLoc(), TII->get(NewOpcode))
287 .addOperand(MI->getOperand(0))
288 .addOperand(MI->getOperand(1));
289 MFI->erase(I);
290 I = static_cast<MachineBasicBlock::iterator>(NewMI);
291 return true;
292 }
293 return false;
294}
295
Eric Christopher31b81ce2014-06-03 21:01:35 +0000296void FixupLEAPass::processInstruction(MachineBasicBlock::iterator &I,
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000297 MachineFunction::iterator MFI) {
298 // Process a load, store, or LEA instruction.
299 MachineInstr *MI = I;
300 int opcode = MI->getOpcode();
Eric Christopher31b81ce2014-06-03 21:01:35 +0000301 const MCInstrDesc &Desc = MI->getDesc();
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000302 int AddrOffset = X86II::getMemoryOperandNo(Desc.TSFlags, opcode);
303 if (AddrOffset >= 0) {
304 AddrOffset += X86II::getOperandBias(Desc);
Eric Christopher31b81ce2014-06-03 21:01:35 +0000305 MachineOperand &p = MI->getOperand(AddrOffset + X86::AddrBaseReg);
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000306 if (p.isReg() && p.getReg() != X86::ESP) {
307 seekLEAFixup(p, I, MFI);
308 }
Eric Christopher31b81ce2014-06-03 21:01:35 +0000309 MachineOperand &q = MI->getOperand(AddrOffset + X86::AddrIndexReg);
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000310 if (q.isReg() && q.getReg() != X86::ESP) {
311 seekLEAFixup(q, I, MFI);
312 }
313 }
314}
315
Eric Christopher31b81ce2014-06-03 21:01:35 +0000316void FixupLEAPass::seekLEAFixup(MachineOperand &p,
317 MachineBasicBlock::iterator &I,
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000318 MachineFunction::iterator MFI) {
319 MachineBasicBlock::iterator MBI = searchBackwards(p, I, MFI);
320 if (MBI) {
Eric Christopher31b81ce2014-06-03 21:01:35 +0000321 MachineInstr *NewMI = postRAConvertToLEA(MFI, MBI);
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000322 if (NewMI) {
323 ++NumLEAs;
Alexey Volkov6226de62014-05-20 08:55:50 +0000324 DEBUG(dbgs() << "FixLEA: Candidate to replace:"; MBI->dump(););
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000325 // now to replace with an equivalent LEA...
Alexey Volkov6226de62014-05-20 08:55:50 +0000326 DEBUG(dbgs() << "FixLEA: Replaced by: "; NewMI->dump(););
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000327 MFI->erase(MBI);
328 MachineBasicBlock::iterator J =
Eric Christopher31b81ce2014-06-03 21:01:35 +0000329 static_cast<MachineBasicBlock::iterator>(NewMI);
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000330 processInstruction(J, MFI);
331 }
332 }
333}
334
Alexey Volkov6226de62014-05-20 08:55:50 +0000335void FixupLEAPass::processInstructionForSLM(MachineBasicBlock::iterator &I,
336 MachineFunction::iterator MFI) {
337 MachineInstr *MI = I;
338 const int opcode = MI->getOpcode();
Michael Kuperstein12982a82015-11-11 11:44:31 +0000339 if (!isLEA(opcode))
Alexey Volkov6226de62014-05-20 08:55:50 +0000340 return;
341 if (MI->getOperand(5).getReg() != 0 || !MI->getOperand(4).isImm() ||
342 !TII->isSafeToClobberEFLAGS(*MFI, I))
343 return;
344 const unsigned DstR = MI->getOperand(0).getReg();
345 const unsigned SrcR1 = MI->getOperand(1).getReg();
346 const unsigned SrcR2 = MI->getOperand(3).getReg();
347 if ((SrcR1 == 0 || SrcR1 != DstR) && (SrcR2 == 0 || SrcR2 != DstR))
348 return;
349 if (MI->getOperand(2).getImm() > 1)
350 return;
351 int addrr_opcode, addri_opcode;
352 switch (opcode) {
Michael Kuperstein12982a82015-11-11 11:44:31 +0000353 default:
354 llvm_unreachable("Unexpected LEA instruction");
Alexey Volkov6226de62014-05-20 08:55:50 +0000355 case X86::LEA16r:
356 addrr_opcode = X86::ADD16rr;
357 addri_opcode = X86::ADD16ri;
358 break;
359 case X86::LEA32r:
360 addrr_opcode = X86::ADD32rr;
361 addri_opcode = X86::ADD32ri;
362 break;
363 case X86::LEA64_32r:
364 case X86::LEA64r:
365 addrr_opcode = X86::ADD64rr;
366 addri_opcode = X86::ADD64ri32;
367 break;
Alexey Volkov6226de62014-05-20 08:55:50 +0000368 }
369 DEBUG(dbgs() << "FixLEA: Candidate to replace:"; I->dump(););
370 DEBUG(dbgs() << "FixLEA: Replaced by: ";);
Craig Topper66f09ad2014-06-08 22:29:17 +0000371 MachineInstr *NewMI = nullptr;
Alexey Volkov6226de62014-05-20 08:55:50 +0000372 const MachineOperand &Dst = MI->getOperand(0);
373 // Make ADD instruction for two registers writing to LEA's destination
374 if (SrcR1 != 0 && SrcR2 != 0) {
375 const MachineOperand &Src1 = MI->getOperand(SrcR1 == DstR ? 1 : 3);
376 const MachineOperand &Src2 = MI->getOperand(SrcR1 == DstR ? 3 : 1);
377 NewMI = BuildMI(*MF, MI->getDebugLoc(), TII->get(addrr_opcode))
378 .addOperand(Dst)
379 .addOperand(Src1)
380 .addOperand(Src2);
381 MFI->insert(I, NewMI);
382 DEBUG(NewMI->dump(););
383 }
384 // Make ADD instruction for immediate
385 if (MI->getOperand(4).getImm() != 0) {
386 const MachineOperand &SrcR = MI->getOperand(SrcR1 == DstR ? 1 : 3);
387 NewMI = BuildMI(*MF, MI->getDebugLoc(), TII->get(addri_opcode))
388 .addOperand(Dst)
389 .addOperand(SrcR)
390 .addImm(MI->getOperand(4).getImm());
391 MFI->insert(I, NewMI);
392 DEBUG(NewMI->dump(););
393 }
394 if (NewMI) {
395 MFI->erase(I);
396 I = static_cast<MachineBasicBlock::iterator>(NewMI);
397 }
398}
399
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000400bool FixupLEAPass::processBasicBlock(MachineFunction &MF,
401 MachineFunction::iterator MFI) {
402
Alexey Volkov6226de62014-05-20 08:55:50 +0000403 for (MachineBasicBlock::iterator I = MFI->begin(); I != MFI->end(); ++I) {
Michael Kuperstein12982a82015-11-11 11:44:31 +0000404 if (OptIncDec)
405 if (fixupIncDec(I, MFI))
406 continue;
407
408 if (OptLEA) {
409 if (MF.getSubtarget<X86Subtarget>().isSLM())
410 processInstructionForSLM(I, MFI);
411 else
412 processInstruction(I, MFI);
413 }
Alexey Volkov6226de62014-05-20 08:55:50 +0000414 }
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000415 return false;
416}