51#define DEBUG_TYPE "ppc-mi-peepholes"
53STATISTIC(RemoveTOCSave,
"Number of TOC saves removed");
55 "Number of functions with multiple TOC saves that must be kept");
56STATISTIC(NumTOCSavesInPrologue,
"Number of TOC saves placed in the prologue");
57STATISTIC(NumEliminatedSExt,
"Number of eliminated sign-extensions");
58STATISTIC(NumEliminatedZExt,
"Number of eliminated zero-extensions");
59STATISTIC(NumOptADDLIs,
"Number of optimized ADD instruction fed by LI");
61 "Number of instructions converted to their immediate form");
63 "Number of functions entered in PPC MI Peepholes");
65 "Number of fixed-point iterations converting reg-reg instructions "
68 "Number of pairs of rotate left, clear left/right collapsed");
70 "Number of pairs of EXTSW and SLDI combined as EXTSWSLI");
72 "Number of LI(8) reg, 0 that are folded to r0 and removed");
76 cl::desc(
"Iterate to a fixed point when attempting to "
77 "convert reg-reg instructions to reg-imm"));
81 cl::desc(
"Convert eligible reg+reg instructions to reg+imm"));
85 cl::desc(
"enable elimination of sign-extensions"),
90 cl::desc(
"enable elimination of zero-extensions"),
95 cl::desc(
"enable optimization of conditional traps"),
99 PeepholeXToICounter,
"ppc-xtoi-peephole",
100 "Controls whether PPC reg+reg to reg+imm peephole is performed on a MI");
103 "Controls whether PPC per opcode peephole is performed on a MI");
118 MachineDominatorTree *MDT;
119 MachinePostDominatorTree *MPDT;
120 MachineBlockFrequencyInfo *MBFI;
121 BlockFrequency EntryFreq;
122 SmallSet<Register, 16> RegsToUpdate;
131 bool eliminateRedundantCompare();
132 bool eliminateRedundantTOCSaves(std::map<MachineInstr *, bool> &TOCSaves);
133 bool combineSEXTAndSHL(MachineInstr &
MI, MachineInstr *&ToErase);
134 bool emitRLDICWhenLoweringJumpTables(MachineInstr &
MI,
135 MachineInstr *&ToErase);
136 void UpdateTOCSaves(std::map<MachineInstr *, bool> &TOCSaves,
144 void addDummyDef(MachineBasicBlock &
MBB, MachineInstr *At,
Register Reg) {
147 void addRegToUpdateWithLine(
Register Reg,
int Line);
148 void convertUnprimedAccPHIs(
const PPCInstrInfo *TII, MachineRegisterInfo *MRI,
149 SmallVectorImpl<MachineInstr *> &PHIs,
154 void getAnalysisUsage(AnalysisUsage &AU)
const override {
157 AU.
addRequired<MachinePostDominatorTreeWrapperPass>();
158 AU.
addRequired<MachineBlockFrequencyInfoWrapperPass>();
162 AU.
addPreserved<MachineBlockFrequencyInfoWrapperPass>();
167 bool runOnMachineFunction(MachineFunction &MF)
override {
171 assert((MF.getRegInfo().use_empty(PPC::X2) ||
172 !MF.getSubtarget<PPCSubtarget>().isUsingPCRelativeCalls()) &&
173 "TOC pointer used in a function using PC-Relative addressing!");
174 if (skipFunction(MF.getFunction()))
179 MF.verify(
this,
"Error in PowerPC MI Peephole optimization, compile with "
180 "-mllvm -disable-ppc-peephole");
186#define addRegToUpdate(R) addRegToUpdateWithLine(R, __LINE__)
187void PPCMIPeephole::addRegToUpdateWithLine(
Register Reg,
int Line) {
188 if (!
Reg.isVirtual())
192 << Line <<
" for re-computation of kill flags\n");
196void PPCMIPeephole::initialize(MachineFunction &MFParm) {
199 MDT = &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
200 MPDT = &getAnalysis<MachinePostDominatorTreeWrapperPass>().getPostDomTree();
201 MBFI = &getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI();
202 LV = &getAnalysis<LiveVariablesWrapperPass>().getLV();
205 RegsToUpdate.
clear();
210static MachineInstr *getVRegDefOrNull(MachineOperand *
Op,
211 MachineRegisterInfo *
MRI) {
220 return MRI->getVRegDef(
Reg);
225static unsigned getKnownLeadingZeroCount(
const unsigned Reg,
226 const PPCInstrInfo *
TII,
227 const MachineRegisterInfo *
MRI) {
228 MachineInstr *
MI =
MRI->getVRegDef(
Reg);
229 unsigned Opcode =
MI->getOpcode();
230 if (Opcode == PPC::RLDICL || Opcode == PPC::RLDICL_rec ||
231 Opcode == PPC::RLDCL || Opcode == PPC::RLDCL_rec)
232 return MI->getOperand(3).getImm();
234 if ((Opcode == PPC::RLDIC || Opcode == PPC::RLDIC_rec) &&
235 MI->getOperand(3).getImm() <= 63 -
MI->getOperand(2).getImm())
236 return MI->getOperand(3).getImm();
238 if ((Opcode == PPC::RLWINM || Opcode == PPC::RLWINM_rec ||
239 Opcode == PPC::RLWNM || Opcode == PPC::RLWNM_rec ||
240 Opcode == PPC::RLWINM8 || Opcode == PPC::RLWNM8) &&
241 MI->getOperand(3).getImm() <=
MI->getOperand(4).getImm())
242 return 32 +
MI->getOperand(3).getImm();
244 if (Opcode == PPC::ANDI_rec) {
245 uint16_t
Imm =
MI->getOperand(2).getImm();
249 if (Opcode == PPC::CNTLZW || Opcode == PPC::CNTLZW_rec ||
250 Opcode == PPC::CNTTZW || Opcode == PPC::CNTTZW_rec ||
251 Opcode == PPC::CNTLZW8 || Opcode == PPC::CNTTZW8)
255 if (Opcode == PPC::CNTLZD || Opcode == PPC::CNTLZD_rec ||
256 Opcode == PPC::CNTTZD || Opcode == PPC::CNTTZD_rec)
260 if (Opcode == PPC::LHZ || Opcode == PPC::LHZX ||
261 Opcode == PPC::LHZ8 || Opcode == PPC::LHZX8 ||
262 Opcode == PPC::LHZU || Opcode == PPC::LHZUX ||
263 Opcode == PPC::LHZU8 || Opcode == PPC::LHZUX8)
266 if (Opcode == PPC::LBZ || Opcode == PPC::LBZX ||
267 Opcode == PPC::LBZ8 || Opcode == PPC::LBZX8 ||
268 Opcode == PPC::LBZU || Opcode == PPC::LBZUX ||
269 Opcode == PPC::LBZU8 || Opcode == PPC::LBZUX8)
272 if (Opcode == PPC::AND || Opcode == PPC::AND8 || Opcode == PPC::AND_rec ||
273 Opcode == PPC::AND8_rec)
275 getKnownLeadingZeroCount(
MI->getOperand(1).getReg(),
TII,
MRI),
276 getKnownLeadingZeroCount(
MI->getOperand(2).getReg(),
TII,
MRI));
278 if (Opcode == PPC::OR || Opcode == PPC::OR8 || Opcode == PPC::XOR ||
279 Opcode == PPC::XOR8 || Opcode == PPC::OR_rec ||
280 Opcode == PPC::OR8_rec || Opcode == PPC::XOR_rec ||
281 Opcode == PPC::XOR8_rec)
283 getKnownLeadingZeroCount(
MI->getOperand(1).getReg(),
TII,
MRI),
284 getKnownLeadingZeroCount(
MI->getOperand(2).getReg(),
TII,
MRI));
298void PPCMIPeephole::UpdateTOCSaves(
299 std::map<MachineInstr *, bool> &TOCSaves, MachineInstr *
MI) {
300 assert(
TII->isTOCSaveMI(*
MI) &&
"Expecting a TOC save instruction here");
304 PPCFunctionInfo *FI = MF->
getInfo<PPCFunctionInfo>();
307 BlockFrequency CurrBlockFreq = MBFI->
getBlockFreq(
MI->getParent());
313 if (CurrBlockFreq > EntryFreq || MPDT->
dominates(
MI->getParent(), Entry))
319 for (
auto &TOCSave : TOCSaves)
320 TOCSave.second =
false;
322 TOCSaves[
MI] =
false;
328 for (
auto &
I : TOCSaves) {
329 MachineInstr *CurrInst =
I.first;
350static bool collectUnprimedAccPHIs(MachineRegisterInfo *
MRI,
351 MachineInstr *RootPHI,
352 SmallVectorImpl<MachineInstr *> &PHIs) {
354 unsigned VisitedIndex = 0;
355 while (VisitedIndex < PHIs.
size()) {
356 MachineInstr *VisitedPHI = PHIs[VisitedIndex];
358 PHIOp !=
NumOps; PHIOp += 2) {
362 MachineInstr *
Instr =
MRI->getVRegDef(RegOp);
365 unsigned Opcode =
Instr->getOpcode();
366 if (Opcode == PPC::COPY) {
370 }
else if (Opcode != PPC::IMPLICIT_DEF && Opcode != PPC::PHI)
376 if (Opcode != PPC::PHI)
391void PPCMIPeephole::convertUnprimedAccPHIs(
392 const PPCInstrInfo *
TII, MachineRegisterInfo *
MRI,
393 SmallVectorImpl<MachineInstr *> &PHIs,
Register Dst) {
394 DenseMap<MachineInstr *, MachineInstr *> ChangedPHIMap;
401 for (
unsigned PHIOp = 1,
NumOps =
PHI->getNumOperands(); PHIOp !=
NumOps;
404 MachineInstr *PHIInput =
MRI->getVRegDef(RegOp);
406 assert((Opcode == PPC::COPY || Opcode == PPC::IMPLICIT_DEF ||
407 Opcode == PPC::PHI) &&
408 "Unexpected instruction");
409 if (Opcode == PPC::COPY) {
411 &PPC::ACCRCRegClass &&
412 "Unexpected register class");
414 }
else if (Opcode == PPC::IMPLICIT_DEF) {
415 Register AccReg =
MRI->createVirtualRegister(&PPC::ACCRCRegClass);
417 TII->get(PPC::IMPLICIT_DEF), AccReg);
419 PHI->getOperand(PHIOp + 1)});
420 }
else if (Opcode == PPC::PHI) {
425 "This PHI node should have already been changed.");
426 MachineInstr *PrimedAccPHI = ChangedPHIMap.
lookup(PHIInput);
429 PHI->getOperand(PHIOp + 1)});
439 AccReg =
MRI->createVirtualRegister(&PPC::ACCRCRegClass);
440 MachineInstrBuilder NewPHI =
BuildMI(
441 *
PHI->getParent(),
PHI,
PHI->getDebugLoc(),
TII->get(PPC::PHI), AccReg);
442 for (
auto RegMBB : PHIOps) {
443 NewPHI.
add(RegMBB.first).
add(RegMBB.second);
459bool PPCMIPeephole::simplifyCode() {
461 bool TrapOpt =
false;
462 MachineInstr* ToErase =
nullptr;
463 std::map<MachineInstr *, bool> TOCSaves;
464 const TargetRegisterInfo *
TRI = &
TII->getRegisterInfo();
465 NumFunctionsEnteredInMIPeephole++;
470 bool SomethingChanged =
false;
472 NumFixedPointIterations++;
473 SomethingChanged =
false;
474 for (MachineBasicBlock &
MBB : *MF) {
475 for (MachineInstr &
MI :
MBB) {
476 if (
MI.isDebugInstr())
482 SmallSet<Register, 4> RRToRIRegsToUpdate;
483 if (!
TII->convertToImmediateForm(
MI, RRToRIRegsToUpdate))
485 for (
Register R : RRToRIRegsToUpdate)
489 for (
const MachineOperand &MO :
MI.operands())
496 NumConvertedToImmediateForm++;
497 SomethingChanged =
true;
509 auto recomputeLVForDyingInstr = [&]() {
510 if (RegsToUpdate.
empty())
512 for (MachineOperand &MO : ToErase->
operands()) {
513 if (!MO.isReg() || !MO.isDef() || !RegsToUpdate.
count(MO.getReg()))
516 RegsToUpdate.
erase(RegToUpdate);
520 if (!
MRI->getUniqueVRegDef(RegToUpdate))
521 MO.setReg(PPC::NoRegister);
526 for (MachineBasicBlock &
MBB : *MF) {
527 for (MachineInstr &
MI :
MBB) {
534 recomputeLVForDyingInstr();
547 if (
MI.isDebugInstr())
554 switch (
MI.getOpcode()) {
561 if (!Src.isVirtual() || !Dst.isVirtual())
563 if (
MRI->getRegClass(Src) != &PPC::UACCRCRegClass ||
564 MRI->getRegClass(Dst) != &PPC::ACCRCRegClass)
576 MachineInstr *RootPHI =
MRI->getVRegDef(Src);
580 SmallVector<MachineInstr *, 4> PHIs;
581 if (!collectUnprimedAccPHIs(
MRI, RootPHI, PHIs))
584 convertUnprimedAccPHIs(
TII,
MRI, PHIs, Dst);
594 if (!
MI.getOperand(1).isImm() ||
MI.getOperand(1).getImm() != 0)
596 Register MIDestReg =
MI.getOperand(0).getReg();
598 for (MachineInstr&
UseMI :
MRI->use_instructions(MIDestReg))
599 Folded |=
TII->onlyFoldImmediate(
UseMI,
MI, MIDestReg);
600 if (
MRI->use_nodbg_empty(MIDestReg)) {
601 ++NumLoadImmZeroFoldedAndRemoved;
611 MachineFrameInfo &MFI = MF->getFrameInfo();
613 (!MF->getSubtarget<PPCSubtarget>().isELFv2ABI() &&
614 !MF->getSubtarget<PPCSubtarget>().isAIXABI()))
619 if (
TII->isTOCSaveMI(
MI))
620 UpdateTOCSaves(TOCSaves, &
MI);
623 case PPC::XXPERMDI: {
627 int Immed =
MI.getOperand(3).getImm();
639 TRI->lookThruCopyLike(
MI.getOperand(1).getReg(),
MRI);
641 TRI->lookThruCopyLike(
MI.getOperand(2).getReg(),
MRI);
643 if (!(TrueReg1 == TrueReg2 && TrueReg1.
isVirtual()))
646 MachineInstr *
DefMI =
MRI->getVRegDef(TrueReg1);
657 auto isConversionOfLoadAndSplat = [=]() ->
bool {
658 if (DefOpc != PPC::XVCVDPSXDS && DefOpc != PPC::XVCVDPUXDS)
663 MachineInstr *LoadMI =
MRI->getVRegDef(FeedReg1);
664 if (LoadMI && LoadMI->
getOpcode() == PPC::LXVDSX)
669 if ((Immed == 0 || Immed == 3) &&
670 (DefOpc == PPC::LXVDSX || isConversionOfLoadAndSplat())) {
672 "to load-and-splat/copy: ");
675 MI.getOperand(0).getReg())
676 .
add(
MI.getOperand(1));
684 if (DefOpc == PPC::XXPERMDI) {
692 if (DefReg1 != DefReg2) {
696 if (!(FeedReg1 == FeedReg2 && FeedReg1.
isVirtual()))
700 if (DefImmed == 0 || DefImmed == 3) {
705 MI.getOperand(0).getReg())
706 .
add(
MI.getOperand(1));
715 else if ((Immed == 0 || Immed == 3) && DefImmed == 2) {
720 MI.getOperand(1).setReg(DefReg1);
721 MI.getOperand(2).setReg(DefReg2);
722 MI.getOperand(3).setImm(3 - Immed);
730 else if (Immed == 2 && DefImmed == 2) {
735 MI.getOperand(0).getReg())
742 }
else if ((Immed == 0 || Immed == 3 || Immed == 2) &&
743 DefOpc == PPC::XXPERMDIs &&
753 MI.getOperand(0).getReg())
754 .
add(
MI.getOperand(1));
763 }
else if (Immed == 2 &&
764 (DefOpc == PPC::VSPLTB || DefOpc == PPC::VSPLTH ||
765 DefOpc == PPC::VSPLTW || DefOpc == PPC::XXSPLTW ||
766 DefOpc == PPC::VSPLTISB || DefOpc == PPC::VSPLTISH ||
767 DefOpc == PPC::VSPLTISW)) {
771 LLVM_DEBUG(
dbgs() <<
"Optimizing swap(vsplt(is)?[b|h|w]|xxspltw) => "
772 "copy(vsplt(is)?[b|h|w]|xxspltw): ");
775 MI.getOperand(0).getReg())
776 .
add(
MI.getOperand(1));
778 }
else if ((Immed == 0 || Immed == 3 || Immed == 2) &&
779 TII->isLoadFromConstantPool(
DefMI)) {
781 if (
C &&
C->getType()->isVectorTy() &&
C->getSplatValue()) {
785 <<
"Optimizing swap(splat pattern from constant-pool) "
786 "=> copy(splat pattern from constant-pool): ");
789 MI.getOperand(0).getReg())
790 .
add(
MI.getOperand(1));
799 unsigned MyOpcode =
MI.getOpcode();
800 unsigned OpNo = MyOpcode == PPC::XXSPLTW ? 1 : 2;
802 TRI->lookThruCopyLike(
MI.getOperand(OpNo).getReg(),
MRI);
805 MachineInstr *
DefMI =
MRI->getVRegDef(TrueReg);
809 auto isConvertOfSplat = [=]() ->
bool {
810 if (DefOpcode != PPC::XVCVSPSXWS && DefOpcode != PPC::XVCVSPUXWS)
815 MachineInstr *Splt =
MRI->getVRegDef(ConvReg);
816 return Splt && (Splt->
getOpcode() == PPC::LXVWSX ||
819 bool AlreadySplat = (MyOpcode == DefOpcode) ||
820 (MyOpcode == PPC::VSPLTB && DefOpcode == PPC::VSPLTBs) ||
821 (MyOpcode == PPC::VSPLTH && DefOpcode == PPC::VSPLTHs) ||
822 (MyOpcode == PPC::XXSPLTW && DefOpcode == PPC::XXSPLTWs) ||
823 (MyOpcode == PPC::XXSPLTW && DefOpcode == PPC::LXVWSX) ||
824 (MyOpcode == PPC::XXSPLTW && DefOpcode == PPC::MTVSRWS)||
825 (MyOpcode == PPC::XXSPLTW && isConvertOfSplat());
832 MI.getOperand(0).getReg())
833 .
add(
MI.getOperand(OpNo));
840 if (DefOpcode == PPC::XXSLDWI) {
846 MI.getOperand(MyOpcode == PPC::XXSPLTW ? 2 : 1).getImm();
847 if (ShiftOp1 == ShiftOp2) {
848 unsigned NewElem = (SplatImm + ShiftImm) & 0x3;
849 if (
MRI->hasOneNonDBGUse(ShiftRes)) {
856 <<
" to " << NewElem <<
" in instruction: ");
860 MI.getOperand(OpNo).setReg(ShiftOp1);
861 MI.getOperand(2).setImm(NewElem);
866 case PPC::XVCVDPSP: {
869 TRI->lookThruCopyLike(
MI.getOperand(1).getReg(),
MRI);
872 MachineInstr *
DefMI =
MRI->getVRegDef(TrueReg);
883 MachineInstr *
P1 =
MRI->getVRegDef(DefsReg1);
884 MachineInstr *P2 =
MRI->getVRegDef(DefsReg2);
892 auto removeFRSPIfPossible = [&](MachineInstr *RoundInstr) {
893 unsigned Opc = RoundInstr->getOpcode();
894 if ((
Opc == PPC::FRSP ||
Opc == PPC::XSRSP) &&
895 MRI->hasOneNonDBGUse(RoundInstr->getOperand(0).getReg())) {
897 Register ConvReg1 = RoundInstr->getOperand(1).getReg();
898 Register FRSPDefines = RoundInstr->getOperand(0).getReg();
899 MachineInstr &
Use = *(
MRI->use_instr_nodbg_begin(FRSPDefines));
900 for (
int i = 0, e =
Use.getNumOperands(); i < e; ++i)
901 if (
Use.getOperand(i).isReg() &&
902 Use.getOperand(i).getReg() == FRSPDefines)
903 Use.getOperand(i).setReg(ConvReg1);
912 ToErase = RoundInstr;
920 removeFRSPIfPossible(P1);
921 removeFRSPIfPossible(P2);
924 removeFRSPIfPossible(P1);
930 case PPC::EXTSH8_32_64: {
932 Register NarrowReg =
MI.getOperand(1).getReg();
936 MachineInstr *SrcMI =
MRI->getVRegDef(NarrowReg);
940 if (SrcOpcode == PPC::LHZ || SrcOpcode == PPC::LHZX) {
947 unsigned Opc = PPC::LHA;
948 bool SourceIsXForm = SrcOpcode == PPC::LHZX;
949 bool MIIs64Bit =
MI.getOpcode() == PPC::EXTSH8 ||
950 MI.getOpcode() == PPC::EXTSH8_32_64;
952 if (SourceIsXForm && MIIs64Bit)
954 else if (SourceIsXForm && !MIIs64Bit)
965 addDummyDef(
MBB, &
MI, NarrowReg);
981 case PPC::EXTSW_32_64: {
983 Register NarrowReg =
MI.getOperand(1).getReg();
987 MachineInstr *SrcMI =
MRI->getVRegDef(NarrowReg);
991 if (SrcOpcode == PPC::LWZ || SrcOpcode == PPC::LWZX) {
999 bool IsWordAligned =
false;
1001 const GlobalVariable *GV =
1005 IsWordAligned =
true;
1009 IsWordAligned =
true;
1016 unsigned Opc = PPC::LWA_32;
1017 bool SourceIsXForm = SrcOpcode == PPC::LWZX;
1018 bool MIIs64Bit =
MI.getOpcode() == PPC::EXTSW ||
1019 MI.getOpcode() == PPC::EXTSW_32_64;
1021 if (SourceIsXForm && MIIs64Bit)
1023 else if (SourceIsXForm && !MIIs64Bit)
1028 if (!IsWordAligned && (
Opc == PPC::LWA ||
Opc == PPC::LWA_32))
1037 addDummyDef(
MBB, &
MI, NarrowReg);
1047 NumEliminatedSExt++;
1048 }
else if (
MI.getOpcode() == PPC::EXTSW_32_64 &&
1049 TII->isSignExtended(NarrowReg,
MRI)) {
1059 TII->promoteInstr32To64ForElimEXTSW(NarrowReg,
MRI, 0, LV);
1063 MF->getRegInfo().createVirtualRegister(&PPC::G8RCRegClass);
1067 MI.getOperand(0).getReg())
1073 NumEliminatedSExt++;
1086 if (
MI.getOperand(2).getImm() != 0)
1093 MachineInstr *SrcMI =
MRI->getVRegDef(SrcReg);
1094 if (!(SrcMI && SrcMI->
getOpcode() == PPC::INSERT_SUBREG &&
1098 MachineInstr *ImpDefMI, *SubRegMI;
1101 if (ImpDefMI->
getOpcode() != PPC::IMPLICIT_DEF)
break;
1104 if (SubRegMI->
getOpcode() == PPC::COPY) {
1107 SrcMI =
MRI->getVRegDef(CopyReg);
1112 unsigned KnownZeroCount =
1114 if (
MI.getOperand(3).getImm() <= KnownZeroCount) {
1117 MI.getOperand(0).getReg())
1122 NumEliminatedZExt++;
1133 auto isSingleUsePHI = [&](MachineOperand *PhiOp) {
1134 assert(PhiOp &&
"Invalid Operand!");
1135 MachineInstr *DefPhiMI = getVRegDefOrNull(PhiOp,
MRI);
1137 return DefPhiMI && (DefPhiMI->
getOpcode() == PPC::PHI) &&
1141 auto dominatesAllSingleUseLIs = [&](MachineOperand *DominatorOp,
1142 MachineOperand *PhiOp) {
1143 assert(PhiOp &&
"Invalid Operand!");
1144 assert(DominatorOp &&
"Invalid Operand!");
1145 MachineInstr *DefPhiMI = getVRegDefOrNull(PhiOp,
MRI);
1146 MachineInstr *DefDomMI = getVRegDefOrNull(DominatorOp,
MRI);
1151 MachineInstr *LiMI =
1163 MachineOperand Op1 =
MI.getOperand(1);
1164 MachineOperand Op2 =
MI.getOperand(2);
1165 if (isSingleUsePHI(&Op2) && dominatesAllSingleUseLIs(&Op1, &Op2))
1167 else if (!isSingleUsePHI(&Op1) || !dominatesAllSingleUseLIs(&Op2, &Op1))
1173 const TargetRegisterClass *TRC =
MI.getOpcode() == PPC::ADD8
1174 ? &PPC::G8RC_and_G8RC_NOX0RegClass
1175 : &PPC::GPRC_and_GPRC_NOR0RegClass;
1176 MRI->setRegClass(DominatorReg, TRC);
1179 MachineInstr *DefPhiMI = getVRegDefOrNull(&Op1,
MRI);
1181 MachineInstr *LiMI = getVRegDefOrNull(&DefPhiMI->
getOperand(i),
MRI);
1199 .addReg(DominatorReg)
1208 MI.getOperand(0).getReg())
1218 Simplified |= emitRLDICWhenLoweringJumpTables(
MI, ToErase) ||
1219 combineSEXTAndSHL(
MI, ToErase);
1223 case PPC::ANDI8_rec:
1224 case PPC::ANDIS_rec:
1225 case PPC::ANDIS8_rec: {
1227 TRI->lookThruCopyLike(
MI.getOperand(1).getReg(),
MRI);
1228 if (!TrueReg.
isVirtual() || !
MRI->hasOneNonDBGUse(TrueReg))
1231 MachineInstr *SrcMI =
MRI->getVRegDef(TrueReg);
1235 unsigned SrcOpCode = SrcMI->
getOpcode();
1236 if (SrcOpCode != PPC::RLDICL && SrcOpCode != PPC::RLDICR)
1241 DstReg =
MI.getOperand(1).getReg();
1242 const TargetRegisterClass *SrcRC =
MRI->getRegClassOrNull(SrcReg);
1243 const TargetRegisterClass *DstRC =
MRI->getRegClassOrNull(DstReg);
1247 uint64_t AndImm =
MI.getOperand(2).getImm();
1248 if (
MI.getOpcode() == PPC::ANDIS_rec ||
1249 MI.getOpcode() == PPC::ANDIS8_rec)
1257 bool PatternResultZero =
1258 (SrcOpCode == PPC::RLDICL && (RZeroAndImm + ImmSrc > 63)) ||
1259 (SrcOpCode == PPC::RLDICR && LZeroAndImm > ImmSrc);
1263 bool PatternRemoveRotate =
1265 ((SrcOpCode == PPC::RLDICL && LZeroAndImm >= ImmSrc) ||
1266 (SrcOpCode == PPC::RLDICR && (RZeroAndImm + ImmSrc > 63)));
1268 if (!PatternResultZero && !PatternRemoveRotate)
1274 if (PatternResultZero)
1275 MI.getOperand(2).setImm(0);
1285 case PPC::RLWINM_rec:
1287 case PPC::RLWINM8_rec: {
1290 Register OrigOp1Reg =
MI.getOperand(1).isReg()
1291 ?
MI.getOperand(1).getReg()
1296 if (
MI.getOperand(1).isReg())
1302 ++NumRotatesCollapsed;
1313 MachineInstr *LiMI1 = getVRegDefOrNull(&
MI.getOperand(1),
MRI);
1314 MachineInstr *LiMI2 = getVRegDefOrNull(&
MI.getOperand(2),
MRI);
1315 bool IsOperand2Immediate =
MI.getOperand(2).isImm();
1318 if (!(LiMI1 && (LiMI1->
getOpcode() == PPC::LI ||
1321 if (!IsOperand2Immediate &&
1322 !(LiMI2 && (LiMI2->
getOpcode() == PPC::LI ||
1326 auto ImmOperand0 =
MI.getOperand(0).getImm();
1328 auto ImmOperand2 = IsOperand2Immediate ?
MI.getOperand(2).getImm()
1333 if ((ImmOperand0 == 31) ||
1334 ((ImmOperand0 & 0x10) &&
1335 ((int64_t)ImmOperand1 < (int64_t)ImmOperand2)) ||
1336 ((ImmOperand0 & 0x8) &&
1337 ((int64_t)ImmOperand1 > (int64_t)ImmOperand2)) ||
1338 ((ImmOperand0 & 0x2) &&
1339 ((uint64_t)ImmOperand1 < (uint64_t)ImmOperand2)) ||
1340 ((ImmOperand0 & 0x1) &&
1341 ((uint64_t)ImmOperand1 > (uint64_t)ImmOperand2)) ||
1342 ((ImmOperand0 & 0x4) && (ImmOperand1 == ImmOperand2))) {
1357 recomputeLVForDyingInstr();
1367 Simplified |= eliminateRedundantTOCSaves(TOCSaves);
1368 PPCFunctionInfo *FI = MF->getInfo<PPCFunctionInfo>();
1370 NumTOCSavesInPrologue++;
1379 if (!
MRI->reg_empty(
Reg))
1386static bool isEqOrNe(MachineInstr *BI) {
1392static bool isSupportedCmpOp(
unsigned opCode) {
1393 return (opCode == PPC::CMPLD || opCode == PPC::CMPD ||
1394 opCode == PPC::CMPLW || opCode == PPC::CMPW ||
1395 opCode == PPC::CMPLDI || opCode == PPC::CMPDI ||
1396 opCode == PPC::CMPLWI || opCode == PPC::CMPWI);
1399static bool is64bitCmpOp(
unsigned opCode) {
1400 return (opCode == PPC::CMPLD || opCode == PPC::CMPD ||
1401 opCode == PPC::CMPLDI || opCode == PPC::CMPDI);
1404static bool isSignedCmpOp(
unsigned opCode) {
1405 return (opCode == PPC::CMPD || opCode == PPC::CMPW ||
1406 opCode == PPC::CMPDI || opCode == PPC::CMPWI);
1409static unsigned getSignedCmpOpCode(
unsigned opCode) {
1410 if (opCode == PPC::CMPLD)
return PPC::CMPD;
1411 if (opCode == PPC::CMPLW)
return PPC::CMPW;
1412 if (opCode == PPC::CMPLDI)
return PPC::CMPDI;
1413 if (opCode == PPC::CMPLWI)
return PPC::CMPWI;
1419static unsigned getPredicateToDecImm(MachineInstr *BI, MachineInstr *CMPI) {
1420 uint64_t
Imm =
CMPI->getOperand(2).getImm();
1421 bool SignedCmp = isSignedCmpOp(
CMPI->getOpcode());
1422 if ((!SignedCmp && Imm == 0) || (SignedCmp && Imm == 0x8000))
1438static unsigned getPredicateToIncImm(MachineInstr *BI, MachineInstr *CMPI) {
1439 uint64_t
Imm =
CMPI->getOperand(2).getImm();
1440 bool SignedCmp = isSignedCmpOp(
CMPI->getOpcode());
1441 if ((!SignedCmp && Imm == 0xFFFF) || (SignedCmp && Imm == 0x7FFF))
1456static unsigned getIncomingRegForBlock(MachineInstr *Phi,
1457 MachineBasicBlock *
MBB) {
1458 for (
unsigned I = 2,
E =
Phi->getNumOperands() + 1;
I !=
E;
I += 2) {
1459 MachineOperand &MO =
Phi->getOperand(
I);
1461 return Phi->getOperand(
I-1).getReg();
1470static unsigned getSrcVReg(
unsigned Reg, MachineBasicBlock *BB1,
1471 MachineBasicBlock *BB2, MachineRegisterInfo *
MRI) {
1472 unsigned SrcReg =
Reg;
1474 unsigned NextReg = SrcReg;
1475 MachineInstr *Inst =
MRI->getVRegDef(SrcReg);
1477 NextReg = getIncomingRegForBlock(Inst, BB1);
1483 if (NextReg == SrcReg || !Register::isVirtualRegister(NextReg))
1490static bool eligibleForCompareElimination(MachineBasicBlock &
MBB,
1491 MachineBasicBlock *&PredMBB,
1492 MachineBasicBlock *&MBBtoMoveCmp,
1493 MachineRegisterInfo *
MRI) {
1495 auto isEligibleBB = [&](MachineBasicBlock &BB) {
1496 auto BII = BB.getFirstInstrTerminator();
1500 if (BB.succ_size() == 2 &&
1501 BII != BB.instr_end() &&
1502 (*BII).getOpcode() == PPC::BCC &&
1503 (*BII).getOperand(1).isReg()) {
1505 Register CndReg = (*BII).getOperand(1).getReg();
1506 if (!CndReg.
isVirtual() || !
MRI->hasOneNonDBGUse(CndReg))
1509 MachineInstr *
CMPI =
MRI->getVRegDef(CndReg);
1511 if (
CMPI->getParent() != &BB)
1515 for (MachineOperand &MO :
CMPI->operands())
1528 auto isEligibleForMoveCmp = [](MachineBasicBlock &BB) {
1529 return BB.succ_size() == 1;
1532 if (!isEligibleBB(
MBB))
1536 if (NumPredBBs == 1) {
1538 if (isEligibleBB(*TmpMBB)) {
1540 MBBtoMoveCmp =
nullptr;
1544 else if (NumPredBBs == 2) {
1549 MachineBasicBlock *Pred1MBB = *PI;
1550 MachineBasicBlock *Pred2MBB = *(PI+1);
1552 if (isEligibleBB(*Pred1MBB) && isEligibleForMoveCmp(*Pred2MBB)) {
1557 else if (isEligibleBB(*Pred2MBB) && isEligibleForMoveCmp(*Pred1MBB)) {
1563 if (Pred1MBB == &
MBB)
1571 for (
int I = 1;
I <= 2;
I++)
1572 if (
CMPI->getOperand(
I).isReg()) {
1573 MachineInstr *Inst =
MRI->getVRegDef(
CMPI->getOperand(
I).getReg());
1579 MBBtoMoveCmp = Pred2MBB;
1590bool PPCMIPeephole::eliminateRedundantTOCSaves(
1591 std::map<MachineInstr *, bool> &TOCSaves) {
1594 for (
auto TOCSave : TOCSaves) {
1595 if (!TOCSave.second) {
1596 TOCSave.first->eraseFromParent();
1632bool PPCMIPeephole::eliminateRedundantCompare() {
1635 for (MachineBasicBlock &MBB2 : *MF) {
1636 MachineBasicBlock *MBB1 =
nullptr, *MBBtoMoveCmp =
nullptr;
1665 if (!eligibleForCompareElimination(MBB2, MBB1, MBBtoMoveCmp,
MRI))
1671 MachineInstr *BI2 = &*MBB2.getFirstInstrTerminator();
1673 bool IsPartiallyRedundant = (MBBtoMoveCmp !=
nullptr);
1677 if (!isSupportedCmpOp(CMPI1->
getOpcode()) ||
1678 !isSupportedCmpOp(CMPI2->
getOpcode()) ||
1682 unsigned NewOpCode = 0;
1683 unsigned NewPredicate1 = 0, NewPredicate2 = 0;
1685 bool SwapOperands =
false;
1696 auto CmpAgainstImmWithSignBit = [](MachineInstr *
I) {
1697 if (!
I->getOperand(2).isImm())
1699 int16_t
Imm = (int16_t)
I->getOperand(2).getImm();
1703 if (isEqOrNe(BI2) && !CmpAgainstImmWithSignBit(CMPI2) &&
1706 else if (isEqOrNe(BI1) && !CmpAgainstImmWithSignBit(CMPI1) &&
1716 nullptr,
nullptr,
MRI);
1718 nullptr,
nullptr,
MRI);
1724 if (Cmp1Operand1 == Cmp2Operand1 && Cmp1Operand2 == Cmp2Operand2) {
1727 else if (Cmp1Operand1 == Cmp2Operand2 && Cmp1Operand2 == Cmp2Operand1) {
1734 SwapOperands =
true;
1742 nullptr,
nullptr,
MRI);
1745 if (Cmp1Operand1 != Cmp2Operand1)
1753 if (Imm1 != Imm2 && (!isEqOrNe(BI2) || !isEqOrNe(BI1))) {
1754 int Diff = Imm1 - Imm2;
1755 if (Diff < -2 || Diff > 2)
1758 unsigned PredToInc1 = getPredicateToIncImm(BI1, CMPI1);
1759 unsigned PredToDec1 = getPredicateToDecImm(BI1, CMPI1);
1760 unsigned PredToInc2 = getPredicateToIncImm(BI2, CMPI2);
1761 unsigned PredToDec2 = getPredicateToDecImm(BI2, CMPI2);
1763 if (PredToInc2 && PredToDec1) {
1764 NewPredicate2 = PredToInc2;
1765 NewPredicate1 = PredToDec1;
1770 else if (Diff == 1) {
1773 NewPredicate2 = PredToInc2;
1775 else if (PredToDec1) {
1777 NewPredicate1 = PredToDec1;
1780 else if (Diff == -1) {
1783 NewPredicate2 = PredToDec2;
1785 else if (PredToInc1) {
1787 NewPredicate1 = PredToInc1;
1790 else if (Diff == -2) {
1791 if (PredToDec2 && PredToInc1) {
1792 NewPredicate2 = PredToDec2;
1793 NewPredicate1 = PredToInc1;
1805 LLVM_DEBUG(
dbgs() <<
"Optimize two pairs of compare and branch:\n");
1810 for (
const MachineOperand &MO : CMPI1->
operands())
1813 for (
const MachineOperand &MO : CMPI2->
operands())
1818 if (NewOpCode != 0 && NewOpCode != CMPI1->
getOpcode()) {
1821 if (NewPredicate1) {
1824 if (NewPredicate2) {
1831 if (IsPartiallyRedundant) {
1843 for (
int I = 1;
I <= 2;
I++) {
1850 "We cannot support if an operand comes from this BB.");
1851 unsigned SrcReg = getIncomingRegForBlock(Inst, MBBtoMoveCmp);
1860 Register NewVReg =
MRI->createVirtualRegister(&PPC::CRRCRegClass);
1862 TII->get(PPC::PHI), NewVReg)
1885 if (IsPartiallyRedundant) {
1888 <<
" to handle partial redundancy.\n");
1900bool PPCMIPeephole::emitRLDICWhenLoweringJumpTables(MachineInstr &
MI,
1901 MachineInstr *&ToErase) {
1902 if (
MI.getOpcode() != PPC::RLDICR)
1909 MachineInstr *SrcMI =
MRI->getVRegDef(SrcReg);
1913 MachineOperand MOpSHSrc = SrcMI->
getOperand(2);
1914 MachineOperand MOpMBSrc = SrcMI->
getOperand(3);
1915 MachineOperand MOpSHMI =
MI.getOperand(2);
1916 MachineOperand MOpMEMI =
MI.getOperand(3);
1921 uint64_t SHSrc = MOpSHSrc.
getImm();
1922 uint64_t MBSrc = MOpMBSrc.
getImm();
1923 uint64_t SHMI = MOpSHMI.
getImm();
1924 uint64_t MEMI = MOpMEMI.
getImm();
1925 uint64_t NewSH = SHSrc + SHMI;
1926 uint64_t NewMB = MBSrc - SHMI;
1927 if (NewMB > 63 || NewSH > 63)
1936 if ((63 - NewSH) != MEMI)
1943 MI.setDesc(
TII->get(PPC::RLDIC));
1945 MI.getOperand(2).setImm(NewSH);
1946 MI.getOperand(3).setImm(NewMB);
1952 NumRotatesCollapsed++;
1954 if (
MRI->use_nodbg_empty(SrcReg)) {
1956 "Not expecting an implicit def with this instr.");
1973bool PPCMIPeephole::combineSEXTAndSHL(MachineInstr &
MI,
1974 MachineInstr *&ToErase) {
1975 if (
MI.getOpcode() != PPC::RLDICR)
1978 if (!MF->getSubtarget<PPCSubtarget>().isISA3_0())
1981 assert(
MI.getNumOperands() == 4 &&
"RLDICR should have 4 operands");
1983 MachineOperand MOpSHMI =
MI.getOperand(2);
1984 MachineOperand MOpMEMI =
MI.getOperand(3);
1988 uint64_t SHMI = MOpSHMI.
getImm();
1989 uint64_t MEMI = MOpMEMI.
getImm();
1990 if (SHMI + MEMI != 63)
1997 MachineInstr *SrcMI =
MRI->getVRegDef(SrcReg);
2004 if (!
MRI->hasOneNonDBGUse(SrcReg))
2009 "EXTSW's second operand should be a register");
2017 MachineInstr *NewInstr =
2019 SrcMI->
getOpcode() == PPC::EXTSW ?
TII->get(PPC::EXTSWSLI)
2020 :
TII->get(PPC::EXTSWSLI_32_64),
2021 MI.getOperand(0).getReg())
2028 ++NumEXTSWAndSLDICombined;
2041 "PowerPC MI Peephole Optimization",
false,
false)
2049char PPCMIPeephole::
ID = 0;
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file provides an implementation of debug counters.
#define DEBUG_COUNTER(VARNAME, COUNTERNAME, DESC)
static Register UseReg(const MachineOperand &MO)
const HexagonInstrInfo * TII
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
Register const TargetRegisterInfo * TRI
Promote Memory to Register
#define addRegToUpdate(R)
static cl::opt< bool > EnableZExtElimination("ppc-eliminate-zeroext", cl::desc("enable elimination of zero-extensions"), cl::init(true), cl::Hidden)
static cl::opt< bool > FixedPointRegToImm("ppc-reg-to-imm-fixed-point", cl::Hidden, cl::init(true), cl::desc("Iterate to a fixed point when attempting to " "convert reg-reg instructions to reg-imm"))
static cl::opt< bool > EnableTrapOptimization("ppc-opt-conditional-trap", cl::desc("enable optimization of conditional traps"), cl::init(false), cl::Hidden)
static cl::opt< bool > ConvertRegReg("ppc-convert-rr-to-ri", cl::Hidden, cl::init(true), cl::desc("Convert eligible reg+reg instructions to reg+imm"))
static cl::opt< bool > EnableSExtElimination("ppc-eliminate-signext", cl::desc("enable elimination of sign-extensions"), cl::init(true), cl::Hidden)
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)
Initialize the set of available library functions based on the specified target triple.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
static bool shouldExecute(unsigned CounterName)
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
bool dominates(const DomTreeNodeBase< NodeT > *A, const DomTreeNodeBase< NodeT > *B) const
dominates - Returns true iff A dominates B.
FunctionPass class - This class is used to implement most global optimizations.
MaybeAlign getAlign() const
Returns the alignment of the given variable.
LLVM_ABI void recomputeForSingleDefVirtReg(Register Reg)
Recompute liveness from scratch for a virtual register Reg that is known to have a single def that do...
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
unsigned pred_size() const
LLVM_ABI iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
SmallVectorImpl< MachineBasicBlock * >::iterator pred_iterator
pred_iterator pred_begin()
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
LLVM_ABI instr_iterator getFirstInstrTerminator()
Same getFirstTerminator but it ignores bundles and return an instr_iterator instead.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
MachineInstrBundleIterator< MachineInstr > iterator
LLVM_ABI BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const
getblockFreq - Return block frequency.
LLVM_ABI BlockFrequency getEntryFreq() const
Divide a block's BlockFrequency::getFrequency() value by this value to obtain the entry block - relat...
Analysis pass which computes a MachineDominatorTree.
bool dominates(const MachineInstr *A, const MachineInstr *B) const
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void dump() const
dump - Print the current MachineFunction to cerr, useful for debugger use.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const MachineBasicBlock & front() const
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
MachineInstr * getInstr() const
If conversion operators fail, use this method to get the MachineInstr explicitly.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineBasicBlock * getParent() const
unsigned getNumOperands() const
Retuns the total number of operands.
bool hasImplicitDef() const
Returns true if the instruction has implicit definition.
mop_range explicit_uses()
LLVM_ABI void setDesc(const MCInstrDesc &TID)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
LLVM_ABI void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
LLVM_ABI void removeOperand(unsigned OpNo)
Erase an operand from an instruction, leaving it with one fewer operand than it started with.
LLVM_ABI void dump() const
const MachineOperand & getOperand(unsigned i) const
const GlobalValue * getGlobal() const
void setImm(int64_t immVal)
bool isReg() const
isReg - Tests if this is a MO_Register operand.
MachineBasicBlock * getMBB() const
LLVM_ABI void setReg(Register Reg)
Change the register this operand corresponds to.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
Register getReg() const
getReg - Returns the register number.
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
int64_t getOffset() const
Return the offset from the symbol in this operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
void setMustSaveTOC(bool U)
Wrapper class representing virtual and physical registers.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
void push_back(const T &Elt)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
Predicate getSwappedPredicate(Predicate Opcode)
Assume the condition register is set by MI(a,b), return the predicate if we modify the instructions s...
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
unsigned getPredicateCondition(Predicate Opcode)
Return the condition without hint bits.
Predicate getPredicate(unsigned Condition, unsigned Hint)
Return predicate consisting of specified condition and hint bits.
unsigned getPredicateHint(Predicate Opcode)
Return the hint bits of the predicate.
initializer< Ty > init(const Ty &Val)
NodeAddr< InstrNode * > Instr
NodeAddr< PhiNode * > Phi
NodeAddr< UseNode * > Use
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
int countr_zero(T Val)
Count number of 0's from the least significant bit to the most stopping at the first 1.
int countl_zero(T Val)
Count number of 0's from the most significant bit to the least stopping at the first 1.
auto reverse(ContainerTy &&C)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
DWARFExpression::Operation Op
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
LLVM_ABI Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
@ Keep
No function return thunk.
LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
FunctionPass * createPPCMIPeepholePass()
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.