Lines Matching refs:MI

83     bool PerformTrivialCopyPropagation(MachineInstr *MI,
88 bool hasLivePhysRegDefUses(const MachineInstr *MI,
93 bool PhysRegDefsReach(MachineInstr *CSMI, MachineInstr *MI,
97 bool isCSECandidate(MachineInstr *MI);
99 MachineInstr *CSMI, MachineInstr *MI);
122 bool MachineCSE::PerformTrivialCopyPropagation(MachineInstr *MI,
125 for (MachineOperand &MO : MI->operands()) {
158 DEBUG(dbgs() << "*** to: " << *MI);
159 // Propagate SrcReg of copies to MI.
215 bool MachineCSE::hasLivePhysRegDefUses(const MachineInstr *MI,
221 for (const MachineOperand &MO : MI->operands()) {
238 MachineBasicBlock::const_iterator I = MI; I = std::next(I);
239 for (const MachineOperand &MO : MI->operands()) {
265 bool MachineCSE::PhysRegDefsReach(MachineInstr *CSMI, MachineInstr *MI,
272 const MachineBasicBlock *MBB = MI->getParent();
289 MachineBasicBlock::const_iterator E = MI;
298 assert(CrossMBB && "Reaching end-of-MBB without finding MI?");
331 bool MachineCSE::isCSECandidate(MachineInstr *MI) {
332 if (MI->isPosition() || MI->isPHI() || MI->isImplicitDef() || MI->isKill() ||
333 MI->isInlineAsm() || MI->isDebugValue())
337 if (MI->isCopyLike())
341 if (MI->mayStore() || MI->isCall() || MI->isTerminator() ||
342 MI->hasUnmodeledSideEffects())
345 if (MI->mayLoad()) {
349 if (!MI->isInvariantLoad(AA))
358 /// isProfitableToCSE - Return true if it's profitable to eliminate MI with a
361 MachineInstr *CSMI, MachineInstr *MI) {
371 for (MachineInstr &MI : MRI->use_nodbg_instructions(CSReg)) {
372 CSUses.insert(&MI);
374 for (MachineInstr &MI : MRI->use_nodbg_instructions(Reg)) {
375 if (!CSUses.count(&MI)) {
386 if (TII->isAsCheapAsAMove(MI)) {
388 MachineBasicBlock *BB = MI->getParent();
396 for (const MachineOperand &MO : MI->operands()) {
405 for (MachineInstr &MI : MRI->use_nodbg_instructions(Reg)) {
407 if (!MI.isCopyLike()) {
420 for (MachineInstr &MI : MRI->use_nodbg_instructions(CSReg)) {
421 HasPHI |= MI.isPHI();
422 CSBBs.insert(MI.getParent());
427 return CSBBs.count(MI->getParent());
451 MachineInstr *MI = &*I;
454 if (!isCSECandidate(MI))
457 bool FoundCSE = VNT.count(MI);
460 if (PerformTrivialCopyPropagation(MI, MBB)) {
463 // After coalescing MI itself may become a copy.
464 if (MI->isCopyLike())
468 FoundCSE = VNT.count(MI);
474 if (!FoundCSE && MI->isCommutable()) {
475 MachineInstr *NewMI = TII->commuteInstruction(MI);
479 if (NewMI != MI) {
484 // MI was changed but it didn't help, commute it back!
485 (void)TII->commuteInstruction(MI);
496 if (FoundCSE && hasLivePhysRegDefUses(MI, MBB, PhysRefs,
506 unsigned CSVN = VNT.lookup(MI);
508 if (PhysRegDefsReach(CSMI, MI, PhysRefs, PhysDefs, CrossMBBPhysDef))
514 VNT.insert(MI, CurrVN++);
515 Exps.push_back(MI);
520 unsigned CSVN = VNT.lookup(MI);
522 DEBUG(dbgs() << "Examining: " << *MI);
527 unsigned NumDefs = MI->getDesc().getNumDefs() +
528 MI->getDesc().getNumImplicitDefs();
530 for (unsigned i = 0, e = MI->getNumOperands(); NumDefs && i != e; ++i) {
531 MachineOperand &MO = MI->getOperand(i);
537 // Go through implicit defs of CSMI and MI, if a def is not dead at MI,
542 // Keep track of implicit defs of CSMI and MI, to clear possibly
556 if (!isProfitableToCSE(NewReg, OldReg, CSMI, MI)) {
589 // Go through implicit defs of CSMI and MI, if a def is not dead at MI,
594 // Go through implicit defs of CSMI and MI, and clear the kill flags on
595 // their uses in all the instructions between CSMI and MI.
599 // subs ... %NZCV<imp-def> <- MI, to be eliminated
601 // Since we eliminated MI, and reused a register imp-def'd by CSMI
602 // (here %NZCV), that register, if it was killed before MI, should have
604 if (CSMI->getParent() == MI->getParent()) {
605 for (MachineBasicBlock::iterator II = CSMI, IE = MI; II != IE; ++II)
628 MI->eraseFromParent();
636 VNT.insert(MI, CurrVN++);
637 Exps.push_back(MI);