52#define DEBUG_TYPE "ppc-mi-peepholes"
54STATISTIC(RemoveTOCSave,
"Number of TOC saves removed");
56 "Number of functions with multiple TOC saves that must be kept");
57STATISTIC(NumTOCSavesInPrologue,
"Number of TOC saves placed in the prologue");
58STATISTIC(NumEliminatedSExt,
"Number of eliminated sign-extensions");
59STATISTIC(NumEliminatedZExt,
"Number of eliminated zero-extensions");
60STATISTIC(NumOptADDLIs,
"Number of optimized ADD instruction fed by LI");
62 "Number of instructions converted to their immediate form");
64 "Number of functions entered in PPC MI Peepholes");
66 "Number of fixed-point iterations converting reg-reg instructions "
69 "Number of pairs of rotate left, clear left/right collapsed");
71 "Number of pairs of EXTSW and SLDI combined as EXTSWSLI");
73 "Number of LI(8) reg, 0 that are folded to r0 and removed");
77 cl::desc(
"Iterate to a fixed point when attempting to "
78 "convert reg-reg instructions to reg-imm"));
82 cl::desc(
"Convert eligible reg+reg instructions to reg+imm"));
86 cl::desc(
"enable elimination of sign-extensions"),
91 cl::desc(
"enable elimination of zero-extensions"),
96 cl::desc(
"enable optimization of conditional traps"),
100 PeepholeXToICounter,
"ppc-xtoi-peephole",
101 "Controls whether PPC reg+reg to reg+imm peephole is performed on a MI");
104 "Controls whether PPC per opcode peephole is performed on a MI");
119 MachineDominatorTree *MDT;
120 MachinePostDominatorTree *MPDT;
121 MachineBlockFrequencyInfo *MBFI;
122 BlockFrequency EntryFreq;
123 SmallSet<Register, 16> RegsToUpdate;
132 bool eliminateRedundantCompare();
133 bool eliminateRedundantTOCSaves(std::map<MachineInstr *, bool> &TOCSaves);
134 bool combineSEXTAndSHL(MachineInstr &
MI, MachineInstr *&ToErase);
135 bool emitRLDICWhenLoweringJumpTables(MachineInstr &
MI,
136 MachineInstr *&ToErase);
137 void UpdateTOCSaves(std::map<MachineInstr *, bool> &TOCSaves,
145 void addDummyDef(MachineBasicBlock &
MBB, MachineInstr *At,
Register Reg) {
148 void addRegToUpdateWithLine(
Register Reg,
int Line);
149 void convertUnprimedAccPHIs(
const PPCInstrInfo *TII, MachineRegisterInfo *MRI,
150 SmallVectorImpl<MachineInstr *> &PHIs,
155 void getAnalysisUsage(AnalysisUsage &AU)
const override {
158 AU.
addRequired<MachinePostDominatorTreeWrapperPass>();
159 AU.
addRequired<MachineBlockFrequencyInfoWrapperPass>();
163 AU.
addPreserved<MachineBlockFrequencyInfoWrapperPass>();
168 bool runOnMachineFunction(MachineFunction &MF)
override {
172 assert((MF.getRegInfo().use_empty(PPC::X2) ||
173 !MF.getSubtarget<PPCSubtarget>().isUsingPCRelativeCalls()) &&
174 "TOC pointer used in a function using PC-Relative addressing!");
175 if (skipFunction(MF.getFunction()))
180 MF.verify(
this,
"Error in PowerPC MI Peephole optimization, compile with "
181 "-mllvm -disable-ppc-peephole");
187#define addRegToUpdate(R) addRegToUpdateWithLine(R, __LINE__)
188void PPCMIPeephole::addRegToUpdateWithLine(
Register Reg,
int Line) {
189 if (!
Reg.isVirtual())
193 << Line <<
" for re-computation of kill flags\n");
197void PPCMIPeephole::initialize(MachineFunction &MFParm) {
200 MDT = &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
201 MPDT = &getAnalysis<MachinePostDominatorTreeWrapperPass>().getPostDomTree();
202 MBFI = &getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI();
203 LV = &getAnalysis<LiveVariablesWrapperPass>().getLV();
206 RegsToUpdate.
clear();
211static MachineInstr *getVRegDefOrNull(MachineOperand *
Op,
212 MachineRegisterInfo *
MRI) {
221 return MRI->getVRegDef(
Reg);
226static unsigned getKnownLeadingZeroCount(
const unsigned Reg,
227 const PPCInstrInfo *
TII,
228 const MachineRegisterInfo *
MRI) {
229 MachineInstr *
MI =
MRI->getVRegDef(
Reg);
230 unsigned Opcode =
MI->getOpcode();
231 if (Opcode == PPC::RLDICL || Opcode == PPC::RLDICL_rec ||
232 Opcode == PPC::RLDCL || Opcode == PPC::RLDCL_rec)
233 return MI->getOperand(3).getImm();
235 if ((Opcode == PPC::RLDIC || Opcode == PPC::RLDIC_rec) &&
236 MI->getOperand(3).getImm() <= 63 -
MI->getOperand(2).getImm())
237 return MI->getOperand(3).getImm();
239 if ((Opcode == PPC::RLWINM || Opcode == PPC::RLWINM_rec ||
240 Opcode == PPC::RLWNM || Opcode == PPC::RLWNM_rec ||
241 Opcode == PPC::RLWINM8 || Opcode == PPC::RLWNM8) &&
242 MI->getOperand(3).getImm() <=
MI->getOperand(4).getImm())
243 return 32 +
MI->getOperand(3).getImm();
245 if (Opcode == PPC::ANDI_rec) {
246 uint16_t
Imm =
MI->getOperand(2).getImm();
250 if (Opcode == PPC::CNTLZW || Opcode == PPC::CNTLZW_rec ||
251 Opcode == PPC::CNTTZW || Opcode == PPC::CNTTZW_rec ||
252 Opcode == PPC::CNTLZW8 || Opcode == PPC::CNTTZW8)
256 if (Opcode == PPC::CNTLZD || Opcode == PPC::CNTLZD_rec ||
257 Opcode == PPC::CNTTZD || Opcode == PPC::CNTTZD_rec)
261 if (Opcode == PPC::LHZ || Opcode == PPC::LHZX ||
262 Opcode == PPC::LHZ8 || Opcode == PPC::LHZX8 ||
263 Opcode == PPC::LHZU || Opcode == PPC::LHZUX ||
264 Opcode == PPC::LHZU8 || Opcode == PPC::LHZUX8)
267 if (Opcode == PPC::LBZ || Opcode == PPC::LBZX ||
268 Opcode == PPC::LBZ8 || Opcode == PPC::LBZX8 ||
269 Opcode == PPC::LBZU || Opcode == PPC::LBZUX ||
270 Opcode == PPC::LBZU8 || Opcode == PPC::LBZUX8)
273 if (Opcode == PPC::AND || Opcode == PPC::AND8 || Opcode == PPC::AND_rec ||
274 Opcode == PPC::AND8_rec)
276 getKnownLeadingZeroCount(
MI->getOperand(1).getReg(),
TII,
MRI),
277 getKnownLeadingZeroCount(
MI->getOperand(2).getReg(),
TII,
MRI));
279 if (Opcode == PPC::OR || Opcode == PPC::OR8 || Opcode == PPC::XOR ||
280 Opcode == PPC::XOR8 || Opcode == PPC::OR_rec ||
281 Opcode == PPC::OR8_rec || Opcode == PPC::XOR_rec ||
282 Opcode == PPC::XOR8_rec)
284 getKnownLeadingZeroCount(
MI->getOperand(1).getReg(),
TII,
MRI),
285 getKnownLeadingZeroCount(
MI->getOperand(2).getReg(),
TII,
MRI));
299void PPCMIPeephole::UpdateTOCSaves(
300 std::map<MachineInstr *, bool> &TOCSaves, MachineInstr *
MI) {
301 assert(
TII->isTOCSaveMI(*
MI) &&
"Expecting a TOC save instruction here");
305 PPCFunctionInfo *FI = MF->
getInfo<PPCFunctionInfo>();
308 BlockFrequency CurrBlockFreq = MBFI->
getBlockFreq(
MI->getParent());
314 if (CurrBlockFreq > EntryFreq || MPDT->
dominates(
MI->getParent(), Entry))
320 for (
auto &TOCSave : TOCSaves)
321 TOCSave.second =
false;
323 TOCSaves[
MI] =
false;
329 for (
auto &
I : TOCSaves) {
330 MachineInstr *CurrInst =
I.first;
351static bool collectUnprimedAccPHIs(MachineRegisterInfo *
MRI,
352 MachineInstr *RootPHI,
353 SmallVectorImpl<MachineInstr *> &PHIs) {
355 unsigned VisitedIndex = 0;
356 while (VisitedIndex < PHIs.
size()) {
357 MachineInstr *VisitedPHI = PHIs[VisitedIndex];
359 PHIOp !=
NumOps; PHIOp += 2) {
363 MachineInstr *
Instr =
MRI->getVRegDef(RegOp);
366 unsigned Opcode =
Instr->getOpcode();
367 if (Opcode == PPC::COPY) {
371 }
else if (Opcode != PPC::IMPLICIT_DEF && Opcode != PPC::PHI)
377 if (Opcode != PPC::PHI)
392void PPCMIPeephole::convertUnprimedAccPHIs(
393 const PPCInstrInfo *
TII, MachineRegisterInfo *
MRI,
394 SmallVectorImpl<MachineInstr *> &PHIs,
Register Dst) {
395 DenseMap<MachineInstr *, MachineInstr *> ChangedPHIMap;
402 for (
unsigned PHIOp = 1,
NumOps =
PHI->getNumOperands(); PHIOp !=
NumOps;
405 MachineInstr *PHIInput =
MRI->getVRegDef(RegOp);
407 assert((Opcode == PPC::COPY || Opcode == PPC::IMPLICIT_DEF ||
408 Opcode == PPC::PHI) &&
409 "Unexpected instruction");
410 if (Opcode == PPC::COPY) {
412 &PPC::ACCRCRegClass &&
413 "Unexpected register class");
415 }
else if (Opcode == PPC::IMPLICIT_DEF) {
416 Register AccReg =
MRI->createVirtualRegister(&PPC::ACCRCRegClass);
418 TII->get(PPC::IMPLICIT_DEF), AccReg);
420 PHI->getOperand(PHIOp + 1)});
421 }
else if (Opcode == PPC::PHI) {
426 "This PHI node should have already been changed.");
427 MachineInstr *PrimedAccPHI = ChangedPHIMap.
lookup(PHIInput);
430 PHI->getOperand(PHIOp + 1)});
440 AccReg =
MRI->createVirtualRegister(&PPC::ACCRCRegClass);
441 MachineInstrBuilder NewPHI =
BuildMI(
442 *
PHI->getParent(),
PHI,
PHI->getDebugLoc(),
TII->get(PPC::PHI), AccReg);
443 for (
auto RegMBB : PHIOps) {
444 NewPHI.
add(RegMBB.first).
add(RegMBB.second);
460bool PPCMIPeephole::simplifyCode() {
462 bool TrapOpt =
false;
463 MachineInstr* ToErase =
nullptr;
464 std::map<MachineInstr *, bool> TOCSaves;
466 NumFunctionsEnteredInMIPeephole++;
471 bool SomethingChanged =
false;
473 NumFixedPointIterations++;
474 SomethingChanged =
false;
475 for (MachineBasicBlock &
MBB : *MF) {
476 for (MachineInstr &
MI :
MBB) {
477 if (
MI.isDebugInstr())
483 SmallSet<Register, 4> RRToRIRegsToUpdate;
484 if (!
TII->convertToImmediateForm(
MI, RRToRIRegsToUpdate))
486 for (
Register R : RRToRIRegsToUpdate)
490 for (
const MachineOperand &MO :
MI.operands())
497 NumConvertedToImmediateForm++;
498 SomethingChanged =
true;
510 auto recomputeLVForDyingInstr = [&]() {
511 if (RegsToUpdate.
empty())
513 for (MachineOperand &MO : ToErase->
operands()) {
514 if (!MO.isReg() || !MO.isDef() || !RegsToUpdate.
count(MO.getReg()))
517 RegsToUpdate.
erase(RegToUpdate);
521 if (!
MRI->getUniqueVRegDef(RegToUpdate))
522 MO.setReg(PPC::NoRegister);
527 for (MachineBasicBlock &
MBB : *MF) {
528 for (MachineInstr &
MI :
MBB) {
535 recomputeLVForDyingInstr();
548 if (
MI.isDebugInstr())
555 switch (
MI.getOpcode()) {
562 if (!Src.isVirtual() || !Dst.isVirtual())
564 if (
MRI->getRegClass(Src) != &PPC::UACCRCRegClass ||
565 MRI->getRegClass(Dst) != &PPC::ACCRCRegClass)
577 MachineInstr *RootPHI =
MRI->getVRegDef(Src);
581 SmallVector<MachineInstr *, 4> PHIs;
582 if (!collectUnprimedAccPHIs(
MRI, RootPHI, PHIs))
585 convertUnprimedAccPHIs(
TII,
MRI, PHIs, Dst);
595 if (!
MI.getOperand(1).isImm() ||
MI.getOperand(1).getImm() != 0)
597 Register MIDestReg =
MI.getOperand(0).getReg();
599 for (MachineInstr&
UseMI :
MRI->use_instructions(MIDestReg))
600 Folded |=
TII->onlyFoldImmediate(
UseMI,
MI, MIDestReg);
601 if (
MRI->use_nodbg_empty(MIDestReg)) {
602 ++NumLoadImmZeroFoldedAndRemoved;
612 MachineFrameInfo &MFI = MF->getFrameInfo();
614 (!MF->getSubtarget<PPCSubtarget>().isELFv2ABI() &&
615 !MF->getSubtarget<PPCSubtarget>().isAIXABI()))
620 if (
TII->isTOCSaveMI(
MI))
621 UpdateTOCSaves(TOCSaves, &
MI);
624 case PPC::XXPERMDI: {
628 int Immed =
MI.getOperand(3).getImm();
640 TRI->lookThruCopyLike(
MI.getOperand(1).getReg(),
MRI);
642 TRI->lookThruCopyLike(
MI.getOperand(2).getReg(),
MRI);
644 if (!(TrueReg1 == TrueReg2 && TrueReg1.
isVirtual()))
647 MachineInstr *
DefMI =
MRI->getVRegDef(TrueReg1);
658 auto isConversionOfLoadAndSplat = [=]() ->
bool {
659 if (DefOpc != PPC::XVCVDPSXDS && DefOpc != PPC::XVCVDPUXDS)
664 MachineInstr *LoadMI =
MRI->getVRegDef(FeedReg1);
665 if (LoadMI && LoadMI->
getOpcode() == PPC::LXVDSX)
670 if ((Immed == 0 || Immed == 3) &&
671 (DefOpc == PPC::LXVDSX || isConversionOfLoadAndSplat())) {
673 "to load-and-splat/copy: ");
676 MI.getOperand(0).getReg())
677 .
add(
MI.getOperand(1));
685 if (DefOpc == PPC::XXPERMDI) {
693 if (DefReg1 != DefReg2) {
697 if (!(FeedReg1 == FeedReg2 && FeedReg1.
isVirtual()))
701 if (DefImmed == 0 || DefImmed == 3) {
706 MI.getOperand(0).getReg())
707 .
add(
MI.getOperand(1));
716 else if ((Immed == 0 || Immed == 3) && DefImmed == 2) {
721 MI.getOperand(1).setReg(DefReg1);
722 MI.getOperand(2).setReg(DefReg2);
723 MI.getOperand(3).setImm(3 - Immed);
731 else if (Immed == 2 && DefImmed == 2) {
736 MI.getOperand(0).getReg())
743 }
else if ((Immed == 0 || Immed == 3 || Immed == 2) &&
744 DefOpc == PPC::XXPERMDIs &&
754 MI.getOperand(0).getReg())
755 .
add(
MI.getOperand(1));
764 }
else if (Immed == 2 &&
765 (DefOpc == PPC::VSPLTB || DefOpc == PPC::VSPLTH ||
766 DefOpc == PPC::VSPLTW || DefOpc == PPC::XXSPLTW ||
767 DefOpc == PPC::VSPLTISB || DefOpc == PPC::VSPLTISH ||
768 DefOpc == PPC::VSPLTISW)) {
772 LLVM_DEBUG(
dbgs() <<
"Optimizing swap(vsplt(is)?[b|h|w]|xxspltw) => "
773 "copy(vsplt(is)?[b|h|w]|xxspltw): ");
776 MI.getOperand(0).getReg())
777 .
add(
MI.getOperand(1));
779 }
else if ((Immed == 0 || Immed == 3 || Immed == 2) &&
780 TII->isLoadFromConstantPool(
DefMI)) {
782 if (
C &&
C->getType()->isVectorTy() &&
C->getSplatValue()) {
786 <<
"Optimizing swap(splat pattern from constant-pool) "
787 "=> copy(splat pattern from constant-pool): ");
790 MI.getOperand(0).getReg())
791 .
add(
MI.getOperand(1));
800 unsigned MyOpcode =
MI.getOpcode();
802 unsigned OpNo = MyOpcode == PPC::XXSPLTW ? 1 : 2;
804 TRI->lookThruCopyLike(
MI.getOperand(OpNo).getReg(),
MRI);
807 MachineInstr *
DefMI =
MRI->getVRegDef(TrueReg);
811 auto isConvertOfSplat = [=]() ->
bool {
812 if (DefOpcode != PPC::XVCVSPSXWS && DefOpcode != PPC::XVCVSPUXWS)
817 MachineInstr *Splt =
MRI->getVRegDef(ConvReg);
818 return Splt && (Splt->
getOpcode() == PPC::LXVWSX ||
821 bool AlreadySplat = (MyOpcode == DefOpcode) ||
822 (MyOpcode == PPC::VSPLTB && DefOpcode == PPC::VSPLTBs) ||
823 (MyOpcode == PPC::VSPLTH && DefOpcode == PPC::VSPLTHs) ||
824 (MyOpcode == PPC::XXSPLTW && DefOpcode == PPC::XXSPLTWs) ||
825 (MyOpcode == PPC::XXSPLTW && DefOpcode == PPC::LXVWSX) ||
826 (MyOpcode == PPC::XXSPLTW && DefOpcode == PPC::MTVSRWS)||
827 (MyOpcode == PPC::XXSPLTW && isConvertOfSplat());
835 MI.getOperand(0).getReg())
836 .
add(
MI.getOperand(OpNo));
844 if (DefOpcode == PPC::XXSLDWI) {
866 unsigned SplatImmNo = MyOpcode == PPC::XXSPLTW ? 2 : 1;
867 unsigned SplatImm =
MI.getOperand(SplatImmNo).getImm();
873 auto CalculateNewElementIdx = [&](
unsigned Opcode) {
874 if (Opcode == PPC::VSPLTB)
875 return (SplatImm + ShiftImm * 4) & 0xF;
876 else if (Opcode == PPC::VSPLTH)
877 return (SplatImm + ShiftImm * 2) & 0x7;
879 return (SplatImm + ShiftImm) & 0x3;
882 unsigned NewElem = CalculateNewElementIdx(MyOpcode);
885 <<
" to " << NewElem <<
" in instruction: ");
889 MI.getOperand(OpNo).setReg(ShiftOp1);
890 MI.getOperand(SplatImmNo).setImm(NewElem);
895 case PPC::XVCVDPSP: {
898 TRI->lookThruCopyLike(
MI.getOperand(1).getReg(),
MRI);
901 MachineInstr *
DefMI =
MRI->getVRegDef(TrueReg);
912 MachineInstr *
P1 =
MRI->getVRegDef(DefsReg1);
913 MachineInstr *P2 =
MRI->getVRegDef(DefsReg2);
921 auto removeFRSPIfPossible = [&](MachineInstr *RoundInstr) {
922 unsigned Opc = RoundInstr->getOpcode();
923 if ((
Opc == PPC::FRSP ||
Opc == PPC::XSRSP) &&
924 MRI->hasOneNonDBGUse(RoundInstr->getOperand(0).getReg())) {
926 Register ConvReg1 = RoundInstr->getOperand(1).getReg();
927 Register FRSPDefines = RoundInstr->getOperand(0).getReg();
928 MachineInstr &
Use = *(
MRI->use_instr_nodbg_begin(FRSPDefines));
929 for (
int i = 0, e =
Use.getNumOperands(); i < e; ++i)
930 if (
Use.getOperand(i).isReg() &&
931 Use.getOperand(i).getReg() == FRSPDefines)
932 Use.getOperand(i).setReg(ConvReg1);
941 ToErase = RoundInstr;
949 removeFRSPIfPossible(P1);
950 removeFRSPIfPossible(P2);
953 removeFRSPIfPossible(P1);
959 case PPC::EXTSH8_32_64: {
961 Register NarrowReg =
MI.getOperand(1).getReg();
965 MachineInstr *SrcMI =
MRI->getVRegDef(NarrowReg);
969 if (SrcOpcode == PPC::LHZ || SrcOpcode == PPC::LHZX) {
976 unsigned Opc = PPC::LHA;
977 bool SourceIsXForm = SrcOpcode == PPC::LHZX;
978 bool MIIs64Bit =
MI.getOpcode() == PPC::EXTSH8 ||
979 MI.getOpcode() == PPC::EXTSH8_32_64;
981 if (SourceIsXForm && MIIs64Bit)
983 else if (SourceIsXForm && !MIIs64Bit)
994 addDummyDef(
MBB, &
MI, NarrowReg);
1004 NumEliminatedSExt++;
1010 case PPC::EXTSW_32_64: {
1012 Register NarrowReg =
MI.getOperand(1).getReg();
1016 MachineInstr *SrcMI =
MRI->getVRegDef(NarrowReg);
1017 unsigned SrcOpcode = SrcMI->
getOpcode();
1020 if (SrcOpcode == PPC::LWZ || SrcOpcode == PPC::LWZX) {
1028 bool IsWordAligned =
false;
1030 const GlobalVariable *GV =
1034 IsWordAligned =
true;
1038 IsWordAligned =
true;
1045 unsigned Opc = PPC::LWA_32;
1046 bool SourceIsXForm = SrcOpcode == PPC::LWZX;
1047 bool MIIs64Bit =
MI.getOpcode() == PPC::EXTSW ||
1048 MI.getOpcode() == PPC::EXTSW_32_64;
1050 if (SourceIsXForm && MIIs64Bit)
1052 else if (SourceIsXForm && !MIIs64Bit)
1057 if (!IsWordAligned && (
Opc == PPC::LWA ||
Opc == PPC::LWA_32))
1066 addDummyDef(
MBB, &
MI, NarrowReg);
1076 NumEliminatedSExt++;
1077 }
else if (
MI.getOpcode() == PPC::EXTSW_32_64 &&
1078 TII->isSignExtended(NarrowReg,
MRI)) {
1088 TII->promoteInstr32To64ForElimEXTSW(NarrowReg,
MRI, 0, LV);
1092 MF->getRegInfo().createVirtualRegister(&PPC::G8RCRegClass);
1096 MI.getOperand(0).getReg())
1102 NumEliminatedSExt++;
1115 if (
MI.getOperand(2).getImm() != 0)
1122 MachineInstr *SrcMI =
MRI->getVRegDef(SrcReg);
1123 if (!(SrcMI && SrcMI->
getOpcode() == PPC::INSERT_SUBREG &&
1127 MachineInstr *ImpDefMI, *SubRegMI;
1130 if (ImpDefMI->
getOpcode() != PPC::IMPLICIT_DEF)
break;
1133 if (SubRegMI->
getOpcode() == PPC::COPY) {
1136 SrcMI =
MRI->getVRegDef(CopyReg);
1141 unsigned KnownZeroCount =
1143 if (
MI.getOperand(3).getImm() <= KnownZeroCount) {
1146 MI.getOperand(0).getReg())
1151 NumEliminatedZExt++;
1162 auto isSingleUsePHI = [&](MachineOperand *PhiOp) {
1163 assert(PhiOp &&
"Invalid Operand!");
1164 MachineInstr *DefPhiMI = getVRegDefOrNull(PhiOp,
MRI);
1166 return DefPhiMI && (DefPhiMI->
getOpcode() == PPC::PHI) &&
1170 auto dominatesAllSingleUseLIs = [&](MachineOperand *DominatorOp,
1171 MachineOperand *PhiOp) {
1172 assert(PhiOp &&
"Invalid Operand!");
1173 assert(DominatorOp &&
"Invalid Operand!");
1174 MachineInstr *DefPhiMI = getVRegDefOrNull(PhiOp,
MRI);
1175 MachineInstr *DefDomMI = getVRegDefOrNull(DominatorOp,
MRI);
1180 MachineInstr *LiMI =
1192 MachineOperand Op1 =
MI.getOperand(1);
1193 MachineOperand Op2 =
MI.getOperand(2);
1194 if (isSingleUsePHI(&Op2) && dominatesAllSingleUseLIs(&Op1, &Op2))
1196 else if (!isSingleUsePHI(&Op1) || !dominatesAllSingleUseLIs(&Op2, &Op1))
1202 const TargetRegisterClass *TRC =
MI.getOpcode() == PPC::ADD8
1203 ? &PPC::G8RC_and_G8RC_NOX0RegClass
1204 : &PPC::GPRC_and_GPRC_NOR0RegClass;
1205 MRI->setRegClass(DominatorReg, TRC);
1208 MachineInstr *DefPhiMI = getVRegDefOrNull(&Op1,
MRI);
1210 MachineInstr *LiMI = getVRegDefOrNull(&DefPhiMI->
getOperand(i),
MRI);
1228 .addReg(DominatorReg)
1237 MI.getOperand(0).getReg())
1247 Simplified |= emitRLDICWhenLoweringJumpTables(
MI, ToErase) ||
1248 combineSEXTAndSHL(
MI, ToErase);
1252 case PPC::ANDI8_rec:
1253 case PPC::ANDIS_rec:
1254 case PPC::ANDIS8_rec: {
1256 TRI->lookThruCopyLike(
MI.getOperand(1).getReg(),
MRI);
1257 if (!TrueReg.
isVirtual() || !
MRI->hasOneNonDBGUse(TrueReg))
1260 MachineInstr *SrcMI =
MRI->getVRegDef(TrueReg);
1264 unsigned SrcOpCode = SrcMI->
getOpcode();
1265 if (SrcOpCode != PPC::RLDICL && SrcOpCode != PPC::RLDICR)
1270 DstReg =
MI.getOperand(1).getReg();
1271 const TargetRegisterClass *SrcRC =
MRI->getRegClassOrNull(SrcReg);
1272 const TargetRegisterClass *DstRC =
MRI->getRegClassOrNull(DstReg);
1276 uint64_t AndImm =
MI.getOperand(2).getImm();
1277 if (
MI.getOpcode() == PPC::ANDIS_rec ||
1278 MI.getOpcode() == PPC::ANDIS8_rec)
1286 bool PatternResultZero =
1287 (SrcOpCode == PPC::RLDICL && (RZeroAndImm + ImmSrc > 63)) ||
1288 (SrcOpCode == PPC::RLDICR && LZeroAndImm > ImmSrc);
1292 bool PatternRemoveRotate =
1294 ((SrcOpCode == PPC::RLDICL && LZeroAndImm >= ImmSrc) ||
1295 (SrcOpCode == PPC::RLDICR && (RZeroAndImm + ImmSrc > 63)));
1297 if (!PatternResultZero && !PatternRemoveRotate)
1303 if (PatternResultZero)
1304 MI.getOperand(2).setImm(0);
1314 case PPC::RLWINM_rec:
1316 case PPC::RLWINM8_rec: {
1319 Register OrigOp1Reg =
MI.getOperand(1).isReg()
1320 ?
MI.getOperand(1).getReg()
1325 if (
MI.getOperand(1).isReg())
1331 ++NumRotatesCollapsed;
1342 MachineInstr *LiMI1 = getVRegDefOrNull(&
MI.getOperand(1),
MRI);
1343 MachineInstr *LiMI2 = getVRegDefOrNull(&
MI.getOperand(2),
MRI);
1344 bool IsOperand2Immediate =
MI.getOperand(2).isImm();
1347 if (!(LiMI1 && (LiMI1->
getOpcode() == PPC::LI ||
1350 if (!IsOperand2Immediate &&
1351 !(LiMI2 && (LiMI2->
getOpcode() == PPC::LI ||
1355 auto ImmOperand0 =
MI.getOperand(0).getImm();
1357 auto ImmOperand2 = IsOperand2Immediate ?
MI.getOperand(2).getImm()
1362 if ((ImmOperand0 == 31) ||
1363 ((ImmOperand0 & 0x10) &&
1364 ((int64_t)ImmOperand1 < (int64_t)ImmOperand2)) ||
1365 ((ImmOperand0 & 0x8) &&
1366 ((int64_t)ImmOperand1 > (int64_t)ImmOperand2)) ||
1367 ((ImmOperand0 & 0x2) &&
1368 ((uint64_t)ImmOperand1 < (uint64_t)ImmOperand2)) ||
1369 ((ImmOperand0 & 0x1) &&
1370 ((uint64_t)ImmOperand1 > (uint64_t)ImmOperand2)) ||
1371 ((ImmOperand0 & 0x4) && (ImmOperand1 == ImmOperand2))) {
1386 recomputeLVForDyingInstr();
1396 Simplified |= eliminateRedundantTOCSaves(TOCSaves);
1397 PPCFunctionInfo *FI = MF->getInfo<PPCFunctionInfo>();
1399 NumTOCSavesInPrologue++;
1408 if (!
MRI->reg_empty(
Reg))
1415static bool isEqOrNe(MachineInstr *BI) {
1421static bool isSupportedCmpOp(
unsigned opCode) {
1422 return (opCode == PPC::CMPLD || opCode == PPC::CMPD ||
1423 opCode == PPC::CMPLW || opCode == PPC::CMPW ||
1424 opCode == PPC::CMPLDI || opCode == PPC::CMPDI ||
1425 opCode == PPC::CMPLWI || opCode == PPC::CMPWI);
1428static bool is64bitCmpOp(
unsigned opCode) {
1429 return (opCode == PPC::CMPLD || opCode == PPC::CMPD ||
1430 opCode == PPC::CMPLDI || opCode == PPC::CMPDI);
1433static bool isSignedCmpOp(
unsigned opCode) {
1434 return (opCode == PPC::CMPD || opCode == PPC::CMPW ||
1435 opCode == PPC::CMPDI || opCode == PPC::CMPWI);
1438static unsigned getSignedCmpOpCode(
unsigned opCode) {
1439 if (opCode == PPC::CMPLD)
return PPC::CMPD;
1440 if (opCode == PPC::CMPLW)
return PPC::CMPW;
1441 if (opCode == PPC::CMPLDI)
return PPC::CMPDI;
1442 if (opCode == PPC::CMPLWI)
return PPC::CMPWI;
1448static unsigned getPredicateToDecImm(MachineInstr *BI, MachineInstr *CMPI) {
1450 bool SignedCmp = isSignedCmpOp(CMPI->
getOpcode());
1451 if ((!SignedCmp && Imm == 0) || (SignedCmp && Imm == 0x8000))
1467static unsigned getPredicateToIncImm(MachineInstr *BI, MachineInstr *CMPI) {
1469 bool SignedCmp = isSignedCmpOp(CMPI->
getOpcode());
1470 if ((!SignedCmp && Imm == 0xFFFF) || (SignedCmp && Imm == 0x7FFF))
1485static unsigned getIncomingRegForBlock(MachineInstr *Phi,
1486 MachineBasicBlock *
MBB) {
1487 for (
unsigned I = 2,
E =
Phi->getNumOperands() + 1;
I !=
E;
I += 2) {
1488 MachineOperand &MO =
Phi->getOperand(
I);
1490 return Phi->getOperand(
I-1).getReg();
1499static unsigned getSrcVReg(
unsigned Reg, MachineBasicBlock *BB1,
1500 MachineBasicBlock *BB2, MachineRegisterInfo *
MRI) {
1501 unsigned SrcReg =
Reg;
1503 unsigned NextReg = SrcReg;
1504 MachineInstr *Inst =
MRI->getVRegDef(SrcReg);
1506 NextReg = getIncomingRegForBlock(Inst, BB1);
1512 if (NextReg == SrcReg || !Register::isVirtualRegister(NextReg))
1519static bool eligibleForCompareElimination(MachineBasicBlock &
MBB,
1520 MachineBasicBlock *&PredMBB,
1521 MachineBasicBlock *&MBBtoMoveCmp,
1522 MachineRegisterInfo *
MRI) {
1524 auto isEligibleBB = [&](MachineBasicBlock &BB) {
1525 auto BII = BB.getFirstInstrTerminator();
1529 if (BB.succ_size() == 2 &&
1530 BII != BB.instr_end() &&
1531 (*BII).getOpcode() == PPC::BCC &&
1532 (*BII).getOperand(1).isReg()) {
1534 Register CndReg = (*BII).getOperand(1).getReg();
1535 if (!CndReg.
isVirtual() || !
MRI->hasOneNonDBGUse(CndReg))
1538 MachineInstr *CMPI =
MRI->getVRegDef(CndReg);
1544 for (MachineOperand &MO : CMPI->
operands())
1557 auto isEligibleForMoveCmp = [](MachineBasicBlock &BB) {
1558 return BB.succ_size() == 1;
1561 if (!isEligibleBB(
MBB))
1565 if (NumPredBBs == 1) {
1567 if (isEligibleBB(*TmpMBB)) {
1569 MBBtoMoveCmp =
nullptr;
1573 else if (NumPredBBs == 2) {
1578 MachineBasicBlock *Pred1MBB = *PI;
1579 MachineBasicBlock *Pred2MBB = *(PI+1);
1581 if (isEligibleBB(*Pred1MBB) && isEligibleForMoveCmp(*Pred2MBB)) {
1586 else if (isEligibleBB(*Pred2MBB) && isEligibleForMoveCmp(*Pred1MBB)) {
1592 if (Pred1MBB == &
MBB)
1600 for (
int I = 1;
I <= 2;
I++)
1608 MBBtoMoveCmp = Pred2MBB;
1619bool PPCMIPeephole::eliminateRedundantTOCSaves(
1620 std::map<MachineInstr *, bool> &TOCSaves) {
1623 for (
auto TOCSave : TOCSaves) {
1624 if (!TOCSave.second) {
1625 TOCSave.first->eraseFromParent();
1661bool PPCMIPeephole::eliminateRedundantCompare() {
1664 for (MachineBasicBlock &MBB2 : *MF) {
1665 MachineBasicBlock *MBB1 =
nullptr, *MBBtoMoveCmp =
nullptr;
1694 if (!eligibleForCompareElimination(MBB2, MBB1, MBBtoMoveCmp,
MRI))
1700 MachineInstr *BI2 = &*MBB2.getFirstInstrTerminator();
1702 bool IsPartiallyRedundant = (MBBtoMoveCmp !=
nullptr);
1706 if (!isSupportedCmpOp(CMPI1->
getOpcode()) ||
1707 !isSupportedCmpOp(CMPI2->
getOpcode()) ||
1711 unsigned NewOpCode = 0;
1712 unsigned NewPredicate1 = 0, NewPredicate2 = 0;
1714 bool SwapOperands =
false;
1725 auto CmpAgainstImmWithSignBit = [](MachineInstr *
I) {
1726 if (!
I->getOperand(2).isImm())
1728 int16_t
Imm = (int16_t)
I->getOperand(2).getImm();
1732 if (isEqOrNe(BI2) && !CmpAgainstImmWithSignBit(CMPI2) &&
1735 else if (isEqOrNe(BI1) && !CmpAgainstImmWithSignBit(CMPI1) &&
1745 nullptr,
nullptr,
MRI);
1747 nullptr,
nullptr,
MRI);
1753 if (Cmp1Operand1 == Cmp2Operand1 && Cmp1Operand2 == Cmp2Operand2) {
1756 else if (Cmp1Operand1 == Cmp2Operand2 && Cmp1Operand2 == Cmp2Operand1) {
1763 SwapOperands =
true;
1771 nullptr,
nullptr,
MRI);
1774 if (Cmp1Operand1 != Cmp2Operand1)
1782 if (Imm1 != Imm2 && (!isEqOrNe(BI2) || !isEqOrNe(BI1))) {
1783 int Diff = Imm1 - Imm2;
1784 if (Diff < -2 || Diff > 2)
1787 unsigned PredToInc1 = getPredicateToIncImm(BI1, CMPI1);
1788 unsigned PredToDec1 = getPredicateToDecImm(BI1, CMPI1);
1789 unsigned PredToInc2 = getPredicateToIncImm(BI2, CMPI2);
1790 unsigned PredToDec2 = getPredicateToDecImm(BI2, CMPI2);
1792 if (PredToInc2 && PredToDec1) {
1793 NewPredicate2 = PredToInc2;
1794 NewPredicate1 = PredToDec1;
1799 else if (Diff == 1) {
1802 NewPredicate2 = PredToInc2;
1804 else if (PredToDec1) {
1806 NewPredicate1 = PredToDec1;
1809 else if (Diff == -1) {
1812 NewPredicate2 = PredToDec2;
1814 else if (PredToInc1) {
1816 NewPredicate1 = PredToInc1;
1819 else if (Diff == -2) {
1820 if (PredToDec2 && PredToInc1) {
1821 NewPredicate2 = PredToDec2;
1822 NewPredicate1 = PredToInc1;
1834 LLVM_DEBUG(
dbgs() <<
"Optimize two pairs of compare and branch:\n");
1839 for (
const MachineOperand &MO : CMPI1->
operands())
1842 for (
const MachineOperand &MO : CMPI2->
operands())
1847 if (NewOpCode != 0 && NewOpCode != CMPI1->
getOpcode()) {
1850 if (NewPredicate1) {
1853 if (NewPredicate2) {
1860 if (IsPartiallyRedundant) {
1872 for (
int I = 1;
I <= 2;
I++) {
1879 "We cannot support if an operand comes from this BB.");
1880 unsigned SrcReg = getIncomingRegForBlock(Inst, MBBtoMoveCmp);
1889 Register NewVReg =
MRI->createVirtualRegister(&PPC::CRRCRegClass);
1891 TII->get(PPC::PHI), NewVReg)
1914 if (IsPartiallyRedundant) {
1917 <<
" to handle partial redundancy.\n");
1929bool PPCMIPeephole::emitRLDICWhenLoweringJumpTables(MachineInstr &
MI,
1930 MachineInstr *&ToErase) {
1931 if (
MI.getOpcode() != PPC::RLDICR)
1938 MachineInstr *SrcMI =
MRI->getVRegDef(SrcReg);
1942 MachineOperand MOpSHSrc = SrcMI->
getOperand(2);
1943 MachineOperand MOpMBSrc = SrcMI->
getOperand(3);
1944 MachineOperand MOpSHMI =
MI.getOperand(2);
1945 MachineOperand MOpMEMI =
MI.getOperand(3);
1950 uint64_t SHSrc = MOpSHSrc.
getImm();
1951 uint64_t MBSrc = MOpMBSrc.
getImm();
1952 uint64_t SHMI = MOpSHMI.
getImm();
1953 uint64_t MEMI = MOpMEMI.
getImm();
1954 uint64_t NewSH = SHSrc + SHMI;
1955 uint64_t NewMB = MBSrc - SHMI;
1956 if (NewMB > 63 || NewSH > 63)
1965 if ((63 - NewSH) != MEMI)
1972 MI.setDesc(
TII->get(PPC::RLDIC));
1974 MI.getOperand(2).setImm(NewSH);
1975 MI.getOperand(3).setImm(NewMB);
1981 NumRotatesCollapsed++;
1983 if (
MRI->use_nodbg_empty(SrcReg)) {
1985 "Not expecting an implicit def with this instr.");
2002bool PPCMIPeephole::combineSEXTAndSHL(MachineInstr &
MI,
2003 MachineInstr *&ToErase) {
2004 if (
MI.getOpcode() != PPC::RLDICR)
2007 if (!MF->getSubtarget<PPCSubtarget>().isISA3_0())
2010 assert(
MI.getNumOperands() == 4 &&
"RLDICR should have 4 operands");
2012 MachineOperand MOpSHMI =
MI.getOperand(2);
2013 MachineOperand MOpMEMI =
MI.getOperand(3);
2017 uint64_t SHMI = MOpSHMI.
getImm();
2018 uint64_t MEMI = MOpMEMI.
getImm();
2019 if (SHMI + MEMI != 63)
2026 MachineInstr *SrcMI =
MRI->getVRegDef(SrcReg);
2033 if (!
MRI->hasOneNonDBGUse(SrcReg))
2038 "EXTSW's second operand should be a register");
2046 MachineInstr *NewInstr =
2048 SrcMI->
getOpcode() == PPC::EXTSW ?
TII->get(PPC::EXTSWSLI)
2049 :
TII->get(PPC::EXTSWSLI_32_64),
2050 MI.getOperand(0).getReg())
2057 ++NumEXTSWAndSLDICombined;
2070 "PowerPC MI Peephole Optimization",
false,
false)
2078char 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, 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.
const HexagonRegisterInfo & getRegisterInfo() const
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.