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;
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();
801 unsigned OpNo = MyOpcode == PPC::XXSPLTW ? 1 : 2;
803 TRI->lookThruCopyLike(
MI.getOperand(OpNo).getReg(),
MRI);
806 MachineInstr *
DefMI =
MRI->getVRegDef(TrueReg);
810 auto isConvertOfSplat = [=]() ->
bool {
811 if (DefOpcode != PPC::XVCVSPSXWS && DefOpcode != PPC::XVCVSPUXWS)
816 MachineInstr *Splt =
MRI->getVRegDef(ConvReg);
817 return Splt && (Splt->
getOpcode() == PPC::LXVWSX ||
820 bool AlreadySplat = (MyOpcode == DefOpcode) ||
821 (MyOpcode == PPC::VSPLTB && DefOpcode == PPC::VSPLTBs) ||
822 (MyOpcode == PPC::VSPLTH && DefOpcode == PPC::VSPLTHs) ||
823 (MyOpcode == PPC::XXSPLTW && DefOpcode == PPC::XXSPLTWs) ||
824 (MyOpcode == PPC::XXSPLTW && DefOpcode == PPC::LXVWSX) ||
825 (MyOpcode == PPC::XXSPLTW && DefOpcode == PPC::MTVSRWS)||
826 (MyOpcode == PPC::XXSPLTW && isConvertOfSplat());
834 MI.getOperand(0).getReg())
835 .
add(
MI.getOperand(OpNo));
843 if (DefOpcode == PPC::XXSLDWI) {
865 unsigned SplatImmNo = MyOpcode == PPC::XXSPLTW ? 2 : 1;
866 unsigned SplatImm =
MI.getOperand(SplatImmNo).getImm();
872 auto CalculateNewElementIdx = [&](
unsigned Opcode) {
873 if (Opcode == PPC::VSPLTB)
874 return (SplatImm + ShiftImm * 4) & 0xF;
875 else if (Opcode == PPC::VSPLTH)
876 return (SplatImm + ShiftImm * 2) & 0x7;
878 return (SplatImm + ShiftImm) & 0x3;
881 unsigned NewElem = CalculateNewElementIdx(MyOpcode);
884 <<
" to " << NewElem <<
" in instruction: ");
888 MI.getOperand(OpNo).setReg(ShiftOp1);
889 MI.getOperand(SplatImmNo).setImm(NewElem);
894 case PPC::XVCVDPSP: {
897 TRI->lookThruCopyLike(
MI.getOperand(1).getReg(),
MRI);
900 MachineInstr *
DefMI =
MRI->getVRegDef(TrueReg);
911 MachineInstr *
P1 =
MRI->getVRegDef(DefsReg1);
912 MachineInstr *P2 =
MRI->getVRegDef(DefsReg2);
920 auto removeFRSPIfPossible = [&](MachineInstr *RoundInstr) {
921 unsigned Opc = RoundInstr->getOpcode();
922 if ((
Opc == PPC::FRSP ||
Opc == PPC::XSRSP) &&
923 MRI->hasOneNonDBGUse(RoundInstr->getOperand(0).getReg())) {
925 Register ConvReg1 = RoundInstr->getOperand(1).getReg();
926 Register FRSPDefines = RoundInstr->getOperand(0).getReg();
927 MachineInstr &
Use = *(
MRI->use_instr_nodbg_begin(FRSPDefines));
928 for (
int i = 0, e =
Use.getNumOperands(); i < e; ++i)
929 if (
Use.getOperand(i).isReg() &&
930 Use.getOperand(i).getReg() == FRSPDefines)
931 Use.getOperand(i).setReg(ConvReg1);
940 ToErase = RoundInstr;
948 removeFRSPIfPossible(P1);
949 removeFRSPIfPossible(P2);
952 removeFRSPIfPossible(P1);
958 case PPC::EXTSH8_32_64: {
960 Register NarrowReg =
MI.getOperand(1).getReg();
964 MachineInstr *SrcMI =
MRI->getVRegDef(NarrowReg);
968 if (SrcOpcode == PPC::LHZ || SrcOpcode == PPC::LHZX) {
975 unsigned Opc = PPC::LHA;
976 bool SourceIsXForm = SrcOpcode == PPC::LHZX;
977 bool MIIs64Bit =
MI.getOpcode() == PPC::EXTSH8 ||
978 MI.getOpcode() == PPC::EXTSH8_32_64;
980 if (SourceIsXForm && MIIs64Bit)
982 else if (SourceIsXForm && !MIIs64Bit)
993 addDummyDef(
MBB, &
MI, NarrowReg);
1003 NumEliminatedSExt++;
1009 case PPC::EXTSW_32_64: {
1011 Register NarrowReg =
MI.getOperand(1).getReg();
1015 MachineInstr *SrcMI =
MRI->getVRegDef(NarrowReg);
1016 unsigned SrcOpcode = SrcMI->
getOpcode();
1019 if (SrcOpcode == PPC::LWZ || SrcOpcode == PPC::LWZX) {
1027 bool IsWordAligned =
false;
1029 const GlobalVariable *GV =
1033 IsWordAligned =
true;
1037 IsWordAligned =
true;
1044 unsigned Opc = PPC::LWA_32;
1045 bool SourceIsXForm = SrcOpcode == PPC::LWZX;
1046 bool MIIs64Bit =
MI.getOpcode() == PPC::EXTSW ||
1047 MI.getOpcode() == PPC::EXTSW_32_64;
1049 if (SourceIsXForm && MIIs64Bit)
1051 else if (SourceIsXForm && !MIIs64Bit)
1056 if (!IsWordAligned && (
Opc == PPC::LWA ||
Opc == PPC::LWA_32))
1065 addDummyDef(
MBB, &
MI, NarrowReg);
1075 NumEliminatedSExt++;
1076 }
else if (
MI.getOpcode() == PPC::EXTSW_32_64 &&
1077 TII->isSignExtended(NarrowReg,
MRI)) {
1087 TII->promoteInstr32To64ForElimEXTSW(NarrowReg,
MRI, 0, LV);
1091 MF->getRegInfo().createVirtualRegister(&PPC::G8RCRegClass);
1095 MI.getOperand(0).getReg())
1101 NumEliminatedSExt++;
1114 if (
MI.getOperand(2).getImm() != 0)
1121 MachineInstr *SrcMI =
MRI->getVRegDef(SrcReg);
1122 if (!(SrcMI && SrcMI->
getOpcode() == PPC::INSERT_SUBREG &&
1126 MachineInstr *ImpDefMI, *SubRegMI;
1129 if (ImpDefMI->
getOpcode() != PPC::IMPLICIT_DEF)
break;
1132 if (SubRegMI->
getOpcode() == PPC::COPY) {
1135 SrcMI =
MRI->getVRegDef(CopyReg);
1140 unsigned KnownZeroCount =
1142 if (
MI.getOperand(3).getImm() <= KnownZeroCount) {
1145 MI.getOperand(0).getReg())
1150 NumEliminatedZExt++;
1161 auto isSingleUsePHI = [&](MachineOperand *PhiOp) {
1162 assert(PhiOp &&
"Invalid Operand!");
1163 MachineInstr *DefPhiMI = getVRegDefOrNull(PhiOp,
MRI);
1165 return DefPhiMI && (DefPhiMI->
getOpcode() == PPC::PHI) &&
1169 auto dominatesAllSingleUseLIs = [&](MachineOperand *DominatorOp,
1170 MachineOperand *PhiOp) {
1171 assert(PhiOp &&
"Invalid Operand!");
1172 assert(DominatorOp &&
"Invalid Operand!");
1173 MachineInstr *DefPhiMI = getVRegDefOrNull(PhiOp,
MRI);
1174 MachineInstr *DefDomMI = getVRegDefOrNull(DominatorOp,
MRI);
1179 MachineInstr *LiMI =
1191 MachineOperand Op1 =
MI.getOperand(1);
1192 MachineOperand Op2 =
MI.getOperand(2);
1193 if (isSingleUsePHI(&Op2) && dominatesAllSingleUseLIs(&Op1, &Op2))
1195 else if (!isSingleUsePHI(&Op1) || !dominatesAllSingleUseLIs(&Op2, &Op1))
1201 const TargetRegisterClass *TRC =
MI.getOpcode() == PPC::ADD8
1202 ? &PPC::G8RC_and_G8RC_NOX0RegClass
1203 : &PPC::GPRC_and_GPRC_NOR0RegClass;
1204 MRI->setRegClass(DominatorReg, TRC);
1207 MachineInstr *DefPhiMI = getVRegDefOrNull(&Op1,
MRI);
1209 MachineInstr *LiMI = getVRegDefOrNull(&DefPhiMI->
getOperand(i),
MRI);
1227 .addReg(DominatorReg)
1236 MI.getOperand(0).getReg())
1246 Simplified |= emitRLDICWhenLoweringJumpTables(
MI, ToErase) ||
1247 combineSEXTAndSHL(
MI, ToErase);
1251 case PPC::ANDI8_rec:
1252 case PPC::ANDIS_rec:
1253 case PPC::ANDIS8_rec: {
1255 TRI->lookThruCopyLike(
MI.getOperand(1).getReg(),
MRI);
1256 if (!TrueReg.
isVirtual() || !
MRI->hasOneNonDBGUse(TrueReg))
1259 MachineInstr *SrcMI =
MRI->getVRegDef(TrueReg);
1263 unsigned SrcOpCode = SrcMI->
getOpcode();
1264 if (SrcOpCode != PPC::RLDICL && SrcOpCode != PPC::RLDICR)
1269 DstReg =
MI.getOperand(1).getReg();
1270 const TargetRegisterClass *SrcRC =
MRI->getRegClassOrNull(SrcReg);
1271 const TargetRegisterClass *DstRC =
MRI->getRegClassOrNull(DstReg);
1275 uint64_t AndImm =
MI.getOperand(2).getImm();
1276 if (
MI.getOpcode() == PPC::ANDIS_rec ||
1277 MI.getOpcode() == PPC::ANDIS8_rec)
1285 bool PatternResultZero =
1286 (SrcOpCode == PPC::RLDICL && (RZeroAndImm + ImmSrc > 63)) ||
1287 (SrcOpCode == PPC::RLDICR && LZeroAndImm > ImmSrc);
1291 bool PatternRemoveRotate =
1293 ((SrcOpCode == PPC::RLDICL && LZeroAndImm >= ImmSrc) ||
1294 (SrcOpCode == PPC::RLDICR && (RZeroAndImm + ImmSrc > 63)));
1296 if (!PatternResultZero && !PatternRemoveRotate)
1302 if (PatternResultZero)
1303 MI.getOperand(2).setImm(0);
1313 case PPC::RLWINM_rec:
1315 case PPC::RLWINM8_rec: {
1318 Register OrigOp1Reg =
MI.getOperand(1).isReg()
1319 ?
MI.getOperand(1).getReg()
1324 if (
MI.getOperand(1).isReg())
1330 ++NumRotatesCollapsed;
1341 MachineInstr *LiMI1 = getVRegDefOrNull(&
MI.getOperand(1),
MRI);
1342 MachineInstr *LiMI2 = getVRegDefOrNull(&
MI.getOperand(2),
MRI);
1343 bool IsOperand2Immediate =
MI.getOperand(2).isImm();
1346 if (!(LiMI1 && (LiMI1->
getOpcode() == PPC::LI ||
1349 if (!IsOperand2Immediate &&
1350 !(LiMI2 && (LiMI2->
getOpcode() == PPC::LI ||
1354 auto ImmOperand0 =
MI.getOperand(0).getImm();
1356 auto ImmOperand2 = IsOperand2Immediate ?
MI.getOperand(2).getImm()
1361 if ((ImmOperand0 == 31) ||
1362 ((ImmOperand0 & 0x10) &&
1363 ((int64_t)ImmOperand1 < (int64_t)ImmOperand2)) ||
1364 ((ImmOperand0 & 0x8) &&
1365 ((int64_t)ImmOperand1 > (int64_t)ImmOperand2)) ||
1366 ((ImmOperand0 & 0x2) &&
1367 ((uint64_t)ImmOperand1 < (uint64_t)ImmOperand2)) ||
1368 ((ImmOperand0 & 0x1) &&
1369 ((uint64_t)ImmOperand1 > (uint64_t)ImmOperand2)) ||
1370 ((ImmOperand0 & 0x4) && (ImmOperand1 == ImmOperand2))) {
1385 recomputeLVForDyingInstr();
1395 Simplified |= eliminateRedundantTOCSaves(TOCSaves);
1396 PPCFunctionInfo *FI = MF->getInfo<PPCFunctionInfo>();
1398 NumTOCSavesInPrologue++;
1407 if (!
MRI->reg_empty(
Reg))
1414static bool isEqOrNe(MachineInstr *BI) {
1420static bool isSupportedCmpOp(
unsigned opCode) {
1421 return (opCode == PPC::CMPLD || opCode == PPC::CMPD ||
1422 opCode == PPC::CMPLW || opCode == PPC::CMPW ||
1423 opCode == PPC::CMPLDI || opCode == PPC::CMPDI ||
1424 opCode == PPC::CMPLWI || opCode == PPC::CMPWI);
1427static bool is64bitCmpOp(
unsigned opCode) {
1428 return (opCode == PPC::CMPLD || opCode == PPC::CMPD ||
1429 opCode == PPC::CMPLDI || opCode == PPC::CMPDI);
1432static bool isSignedCmpOp(
unsigned opCode) {
1433 return (opCode == PPC::CMPD || opCode == PPC::CMPW ||
1434 opCode == PPC::CMPDI || opCode == PPC::CMPWI);
1437static unsigned getSignedCmpOpCode(
unsigned opCode) {
1438 if (opCode == PPC::CMPLD)
return PPC::CMPD;
1439 if (opCode == PPC::CMPLW)
return PPC::CMPW;
1440 if (opCode == PPC::CMPLDI)
return PPC::CMPDI;
1441 if (opCode == PPC::CMPLWI)
return PPC::CMPWI;
1447static unsigned getPredicateToDecImm(MachineInstr *BI, MachineInstr *CMPI) {
1449 bool SignedCmp = isSignedCmpOp(CMPI->
getOpcode());
1450 if ((!SignedCmp && Imm == 0) || (SignedCmp && Imm == 0x8000))
1466static unsigned getPredicateToIncImm(MachineInstr *BI, MachineInstr *CMPI) {
1468 bool SignedCmp = isSignedCmpOp(CMPI->
getOpcode());
1469 if ((!SignedCmp && Imm == 0xFFFF) || (SignedCmp && Imm == 0x7FFF))
1484static unsigned getIncomingRegForBlock(MachineInstr *Phi,
1485 MachineBasicBlock *
MBB) {
1486 for (
unsigned I = 2,
E =
Phi->getNumOperands() + 1;
I !=
E;
I += 2) {
1487 MachineOperand &MO =
Phi->getOperand(
I);
1489 return Phi->getOperand(
I-1).getReg();
1498static unsigned getSrcVReg(
unsigned Reg, MachineBasicBlock *BB1,
1499 MachineBasicBlock *BB2, MachineRegisterInfo *
MRI) {
1500 unsigned SrcReg =
Reg;
1502 unsigned NextReg = SrcReg;
1503 MachineInstr *Inst =
MRI->getVRegDef(SrcReg);
1505 NextReg = getIncomingRegForBlock(Inst, BB1);
1511 if (NextReg == SrcReg || !Register::isVirtualRegister(NextReg))
1518static bool eligibleForCompareElimination(MachineBasicBlock &
MBB,
1519 MachineBasicBlock *&PredMBB,
1520 MachineBasicBlock *&MBBtoMoveCmp,
1521 MachineRegisterInfo *
MRI) {
1523 auto isEligibleBB = [&](MachineBasicBlock &BB) {
1524 auto BII = BB.getFirstInstrTerminator();
1528 if (BB.succ_size() == 2 &&
1529 BII != BB.instr_end() &&
1530 (*BII).getOpcode() == PPC::BCC &&
1531 (*BII).getOperand(1).isReg()) {
1533 Register CndReg = (*BII).getOperand(1).getReg();
1534 if (!CndReg.
isVirtual() || !
MRI->hasOneNonDBGUse(CndReg))
1537 MachineInstr *CMPI =
MRI->getVRegDef(CndReg);
1543 for (MachineOperand &MO : CMPI->
operands())
1556 auto isEligibleForMoveCmp = [](MachineBasicBlock &BB) {
1557 return BB.succ_size() == 1;
1560 if (!isEligibleBB(
MBB))
1564 if (NumPredBBs == 1) {
1566 if (isEligibleBB(*TmpMBB)) {
1568 MBBtoMoveCmp =
nullptr;
1572 else if (NumPredBBs == 2) {
1577 MachineBasicBlock *Pred1MBB = *PI;
1578 MachineBasicBlock *Pred2MBB = *(PI+1);
1580 if (isEligibleBB(*Pred1MBB) && isEligibleForMoveCmp(*Pred2MBB)) {
1585 else if (isEligibleBB(*Pred2MBB) && isEligibleForMoveCmp(*Pred1MBB)) {
1591 if (Pred1MBB == &
MBB)
1599 for (
int I = 1;
I <= 2;
I++)
1607 MBBtoMoveCmp = Pred2MBB;
1618bool PPCMIPeephole::eliminateRedundantTOCSaves(
1619 std::map<MachineInstr *, bool> &TOCSaves) {
1622 for (
auto TOCSave : TOCSaves) {
1623 if (!TOCSave.second) {
1624 TOCSave.first->eraseFromParent();
1660bool PPCMIPeephole::eliminateRedundantCompare() {
1663 for (MachineBasicBlock &MBB2 : *MF) {
1664 MachineBasicBlock *MBB1 =
nullptr, *MBBtoMoveCmp =
nullptr;
1693 if (!eligibleForCompareElimination(MBB2, MBB1, MBBtoMoveCmp,
MRI))
1699 MachineInstr *BI2 = &*MBB2.getFirstInstrTerminator();
1701 bool IsPartiallyRedundant = (MBBtoMoveCmp !=
nullptr);
1705 if (!isSupportedCmpOp(CMPI1->
getOpcode()) ||
1706 !isSupportedCmpOp(CMPI2->
getOpcode()) ||
1710 unsigned NewOpCode = 0;
1711 unsigned NewPredicate1 = 0, NewPredicate2 = 0;
1713 bool SwapOperands =
false;
1724 auto CmpAgainstImmWithSignBit = [](MachineInstr *
I) {
1725 if (!
I->getOperand(2).isImm())
1727 int16_t
Imm = (int16_t)
I->getOperand(2).getImm();
1731 if (isEqOrNe(BI2) && !CmpAgainstImmWithSignBit(CMPI2) &&
1734 else if (isEqOrNe(BI1) && !CmpAgainstImmWithSignBit(CMPI1) &&
1744 nullptr,
nullptr,
MRI);
1746 nullptr,
nullptr,
MRI);
1752 if (Cmp1Operand1 == Cmp2Operand1 && Cmp1Operand2 == Cmp2Operand2) {
1755 else if (Cmp1Operand1 == Cmp2Operand2 && Cmp1Operand2 == Cmp2Operand1) {
1762 SwapOperands =
true;
1770 nullptr,
nullptr,
MRI);
1773 if (Cmp1Operand1 != Cmp2Operand1)
1781 if (Imm1 != Imm2 && (!isEqOrNe(BI2) || !isEqOrNe(BI1))) {
1782 int Diff = Imm1 - Imm2;
1783 if (Diff < -2 || Diff > 2)
1786 unsigned PredToInc1 = getPredicateToIncImm(BI1, CMPI1);
1787 unsigned PredToDec1 = getPredicateToDecImm(BI1, CMPI1);
1788 unsigned PredToInc2 = getPredicateToIncImm(BI2, CMPI2);
1789 unsigned PredToDec2 = getPredicateToDecImm(BI2, CMPI2);
1791 if (PredToInc2 && PredToDec1) {
1792 NewPredicate2 = PredToInc2;
1793 NewPredicate1 = PredToDec1;
1798 else if (Diff == 1) {
1801 NewPredicate2 = PredToInc2;
1803 else if (PredToDec1) {
1805 NewPredicate1 = PredToDec1;
1808 else if (Diff == -1) {
1811 NewPredicate2 = PredToDec2;
1813 else if (PredToInc1) {
1815 NewPredicate1 = PredToInc1;
1818 else if (Diff == -2) {
1819 if (PredToDec2 && PredToInc1) {
1820 NewPredicate2 = PredToDec2;
1821 NewPredicate1 = PredToInc1;
1833 LLVM_DEBUG(
dbgs() <<
"Optimize two pairs of compare and branch:\n");
1838 for (
const MachineOperand &MO : CMPI1->
operands())
1841 for (
const MachineOperand &MO : CMPI2->
operands())
1846 if (NewOpCode != 0 && NewOpCode != CMPI1->
getOpcode()) {
1849 if (NewPredicate1) {
1852 if (NewPredicate2) {
1859 if (IsPartiallyRedundant) {
1871 for (
int I = 1;
I <= 2;
I++) {
1878 "We cannot support if an operand comes from this BB.");
1879 unsigned SrcReg = getIncomingRegForBlock(Inst, MBBtoMoveCmp);
1888 Register NewVReg =
MRI->createVirtualRegister(&PPC::CRRCRegClass);
1890 TII->
get(PPC::PHI), NewVReg)
1913 if (IsPartiallyRedundant) {
1916 <<
" to handle partial redundancy.\n");
1928bool PPCMIPeephole::emitRLDICWhenLoweringJumpTables(MachineInstr &
MI,
1929 MachineInstr *&ToErase) {
1930 if (
MI.getOpcode() != PPC::RLDICR)
1937 MachineInstr *SrcMI =
MRI->getVRegDef(SrcReg);
1941 MachineOperand MOpSHSrc = SrcMI->
getOperand(2);
1942 MachineOperand MOpMBSrc = SrcMI->
getOperand(3);
1943 MachineOperand MOpSHMI =
MI.getOperand(2);
1944 MachineOperand MOpMEMI =
MI.getOperand(3);
1949 uint64_t SHSrc = MOpSHSrc.
getImm();
1950 uint64_t MBSrc = MOpMBSrc.
getImm();
1951 uint64_t SHMI = MOpSHMI.
getImm();
1952 uint64_t MEMI = MOpMEMI.
getImm();
1953 uint64_t NewSH = SHSrc + SHMI;
1954 uint64_t NewMB = MBSrc - SHMI;
1955 if (NewMB > 63 || NewSH > 63)
1964 if ((63 - NewSH) != MEMI)
1973 MI.getOperand(2).setImm(NewSH);
1974 MI.getOperand(3).setImm(NewMB);
1980 NumRotatesCollapsed++;
1982 if (
MRI->use_nodbg_empty(SrcReg)) {
1984 "Not expecting an implicit def with this instr.");
2001bool PPCMIPeephole::combineSEXTAndSHL(MachineInstr &
MI,
2002 MachineInstr *&ToErase) {
2003 if (
MI.getOpcode() != PPC::RLDICR)
2006 if (!MF->getSubtarget<PPCSubtarget>().isISA3_0())
2009 assert(
MI.getNumOperands() == 4 &&
"RLDICR should have 4 operands");
2011 MachineOperand MOpSHMI =
MI.getOperand(2);
2012 MachineOperand MOpMEMI =
MI.getOperand(3);
2016 uint64_t SHMI = MOpSHMI.
getImm();
2017 uint64_t MEMI = MOpMEMI.
getImm();
2018 if (SHMI + MEMI != 63)
2025 MachineInstr *SrcMI =
MRI->getVRegDef(SrcReg);
2032 if (!
MRI->hasOneNonDBGUse(SrcReg))
2037 "EXTSW's second operand should be a register");
2045 MachineInstr *NewInstr =
2048 :
TII->
get(PPC::EXTSWSLI_32_64),
2049 MI.getOperand(0).getReg())
2056 ++NumEXTSWAndSLDICombined;
2069 "PowerPC MI Peephole Optimization",
false,
false)
2077char PPCMIPeephole::
ID = 0;
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const TargetInstrInfo & TII
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 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, const llvm::StringTable &StandardNames, VectorLibrary VecLib)
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(CounterInfo &Counter)
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...
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
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)
const TargetRegisterInfo & getRegisterInfo() const
#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.