40 #define DEBUG_TYPE "ppc-mi-peepholes" 42 STATISTIC(RemoveTOCSave,
"Number of TOC saves removed");
44 "Number of functions with multiple TOC saves that must be kept");
45 STATISTIC(NumTOCSavesInPrologue,
"Number of TOC saves placed in the prologue");
46 STATISTIC(NumEliminatedSExt,
"Number of eliminated sign-extensions");
47 STATISTIC(NumEliminatedZExt,
"Number of eliminated zero-extensions");
48 STATISTIC(NumOptADDLIs,
"Number of optimized ADD instruction fed by LI");
50 "Number of instructions converted to their immediate form");
51 STATISTIC(NumFunctionsEnteredInMIPeephole,
52 "Number of functions entered in PPC MI Peepholes");
54 "Number of fixed-point iterations converting reg-reg instructions " 57 "Number of pairs of rotate left, clear left/right collapsed");
59 "Number of pairs of EXTSW and SLDI combined as EXTSWSLI");
63 cl::desc(
"Iterate to a fixed point when attempting to " 64 "convert reg-reg instructions to reg-imm"));
68 cl::desc(
"Convert eligible reg+reg instructions to reg+imm"));
72 cl::desc(
"enable elimination of sign-extensions"),
77 cl::desc(
"enable elimination of zero-extensions"),
103 bool simplifyCode(
void);
106 bool eliminateRedundantCompare(
void);
107 bool eliminateRedundantTOCSaves(std::map<MachineInstr *, bool> &TOCSaves);
110 void UpdateTOCSaves(std::map<MachineInstr *, bool> &TOCSaves,
130 return simplifyCode();
138 MDT = &getAnalysis<MachineDominatorTree>();
139 MPDT = &getAnalysis<MachinePostDominatorTree>();
140 MBFI = &getAnalysis<MachineBlockFrequencyInfo>();
149 assert(Op &&
"Invalid Operand!");
165 if (Opcode == PPC::RLDICL || Opcode == PPC::RLDICL_rec ||
166 Opcode == PPC::RLDCL || Opcode == PPC::RLDCL_rec)
169 if ((Opcode == PPC::RLDIC || Opcode == PPC::RLDIC_rec) &&
173 if ((Opcode == PPC::RLWINM || Opcode == PPC::RLWINM_rec ||
174 Opcode == PPC::RLWNM || Opcode == PPC::RLWNM_rec ||
175 Opcode == PPC::RLWINM8 || Opcode == PPC::RLWNM8) &&
179 if (Opcode == PPC::ANDI_rec) {
184 if (Opcode == PPC::CNTLZW || Opcode == PPC::CNTLZW_rec ||
185 Opcode == PPC::CNTTZW || Opcode == PPC::CNTTZW_rec ||
186 Opcode == PPC::CNTLZW8 || Opcode == PPC::CNTTZW8)
190 if (Opcode == PPC::CNTLZD || Opcode == PPC::CNTLZD_rec ||
191 Opcode == PPC::CNTTZD || Opcode == PPC::CNTTZD_rec)
195 if (Opcode == PPC::LHZ || Opcode == PPC::LHZX ||
196 Opcode == PPC::LHZ8 || Opcode == PPC::LHZX8 ||
197 Opcode == PPC::LHZU || Opcode == PPC::LHZUX ||
198 Opcode == PPC::LHZU8 || Opcode == PPC::LHZUX8)
201 if (Opcode == PPC::LBZ || Opcode == PPC::LBZX ||
202 Opcode == PPC::LBZ8 || Opcode == PPC::LBZX8 ||
203 Opcode == PPC::LBZU || Opcode == PPC::LBZUX ||
204 Opcode == PPC::LBZU8 || Opcode == PPC::LBZUX8)
219 void PPCMIPeephole::UpdateTOCSaves(
220 std::map<MachineInstr *, bool> &TOCSaves,
MachineInstr *MI) {
223 "TOC-save removal only supported on ELFv2");
227 uint64_t CurrBlockFreq = MBFI->getBlockFreq(MI->
getParent()).getFrequency();
233 if (CurrBlockFreq > EntryFreq || MPDT->dominates(MI->
getParent(), Entry))
234 FI->setMustSaveTOC(
true);
238 if (FI->mustSaveTOC()) {
239 for (
auto &TOCSave : TOCSaves)
240 TOCSave.second =
false;
242 TOCSaves[
MI] =
false;
247 for (
auto It = TOCSaves.begin(); It != TOCSaves.end(); It++ ) {
251 if (It->second && MDT->
dominates(MI, CurrInst))
264 bool PPCMIPeephole::simplifyCode(
void) {
267 std::map<MachineInstr *, bool> TOCSaves;
269 NumFunctionsEnteredInMIPeephole++;
274 bool SomethingChanged =
false;
276 NumFixedPointIterations++;
277 SomethingChanged =
false;
288 NumConvertedToImmediateForm++;
289 SomethingChanged =
true;
327 UpdateTOCSaves(TOCSaves, &MI);
364 auto isConversionOfLoadAndSplat = [=]() ->
bool {
365 if (DefOpc != PPC::XVCVDPSXDS && DefOpc != PPC::XVCVDPUXDS)
371 if (LoadMI && LoadMI->
getOpcode() == PPC::LXVDSX)
376 if ((Immed == 0 || Immed == 3) &&
377 (DefOpc == PPC::LXVDSX || isConversionOfLoadAndSplat())) {
379 "to load-and-splat/copy: ");
398 if (DefReg1 != DefReg2) {
402 if (!(FeedReg1 == FeedReg2 &&
407 if (DefImmed == 0 || DefImmed == 3) {
421 else if ((Immed == 0 || Immed == 3) && DefImmed == 2) {
432 else if (Immed == 2 && DefImmed == 2) {
441 }
else if ((Immed == 0 || Immed == 3) && DefOpc == PPC::XXPERMDIs &&
458 unsigned OpNo = MyOpcode == PPC::XXSPLTW ? 1 : 2;
467 auto isConvertOfSplat = [=]() ->
bool {
468 if (DefOpcode != PPC::XVCVSPSXWS && DefOpcode != PPC::XVCVSPUXWS)
474 return Splt && (Splt->
getOpcode() == PPC::LXVWSX ||
477 bool AlreadySplat = (MyOpcode == DefOpcode) ||
478 (MyOpcode == PPC::VSPLTB && DefOpcode == PPC::VSPLTBs) ||
479 (MyOpcode == PPC::VSPLTH && DefOpcode == PPC::VSPLTHs) ||
480 (MyOpcode == PPC::XXSPLTW && DefOpcode == PPC::XXSPLTWs) ||
481 (MyOpcode == PPC::XXSPLTW && DefOpcode == PPC::LXVWSX) ||
482 (MyOpcode == PPC::XXSPLTW && DefOpcode == PPC::MTVSRWS)||
483 (MyOpcode == PPC::XXSPLTW && isConvertOfSplat());
497 if (DefOpcode == PPC::XXSLDWI) {
503 if (ShiftOp1 == ShiftOp2) {
504 unsigned NewElem = (SplatImm + ShiftImm) & 0x3;
512 <<
" to " << NewElem <<
" in instruction: ");
520 case PPC::XVCVDPSP: {
546 auto removeFRSPIfPossible = [&](
MachineInstr *RoundInstr) {
547 if (RoundInstr->getOpcode() == PPC::FRSP &&
550 Register ConvReg1 = RoundInstr->getOperand(1).getReg();
551 Register FRSPDefines = RoundInstr->getOperand(0).getReg();
563 RoundInstr->eraseFromParent();
571 removeFRSPIfPossible(P1);
572 removeFRSPIfPossible(P2);
575 removeFRSPIfPossible(P1);
581 case PPC::EXTSH8_32_64: {
594 auto is64Bit = [] (
unsigned Opcode) {
595 return Opcode == PPC::EXTSH8;
597 auto isXForm = [] (
unsigned Opcode) {
598 return Opcode == PPC::LHZX;
600 auto getSextLoadOp = [] (
bool is64Bit,
bool isXForm) {
602 if (isXForm)
return PPC::LHAX8;
603 else return PPC::LHA8;
605 if (isXForm)
return PPC::LHAX;
606 else return PPC::LHA;
625 case PPC::EXTSW_32_64: {
638 auto is64Bit = [] (
unsigned Opcode) {
639 return Opcode == PPC::EXTSW || Opcode == PPC::EXTSW_32_64;
641 auto isXForm = [] (
unsigned Opcode) {
642 return Opcode == PPC::LWZX;
644 auto getSextLoadOp = [] (
bool is64Bit,
bool isXForm) {
646 if (isXForm)
return PPC::LWAX;
647 else return PPC::LWA;
649 if (isXForm)
return PPC::LWAX_32;
650 else return PPC::LWA_32;
664 }
else if (MI.
getOpcode() == PPC::EXTSW_32_64 &&
670 MF->getRegInfo().createVirtualRegister(&PPC::G8RCRegClass);
701 if (!(SrcMI && SrcMI->
getOpcode() == PPC::INSERT_SUBREG &&
708 if (ImpDefMI->
getOpcode() != PPC::IMPLICIT_DEF)
break;
711 if (SubRegMI->
getOpcode() == PPC::COPY) {
717 unsigned KnownZeroCount = getKnownLeadingZeroCount(SrcMI, TII);
737 assert(PhiOp &&
"Invalid Operand!");
740 return DefPhiMI && (DefPhiMI->
getOpcode() == PPC::PHI) &&
746 assert(PhiOp &&
"Invalid Operand!");
747 assert(DominatorOp &&
"Invalid Operand!");
749 MachineInstr *DefDomMI = getVRegDefOrNull(DominatorOp, MRI);
768 if (isSingleUsePHI(&Op2) && dominatesAllSingleUseLIs(&Op1, &Op2))
770 else if (!isSingleUsePHI(&Op1) || !dominatesAllSingleUseLIs(&Op2, &Op1))
777 ? &PPC::G8RC_and_G8RC_NOX0RegClass
778 : &PPC::GPRC_and_GPRC_NOR0RegClass;
802 .addReg(DominatorReg)
819 Simplified |= emitRLDICWhenLoweringJumpTables(MI) ||
820 combineSEXTAndSHL(MI, ToErase);
824 case PPC::RLWINM_rec:
826 case PPC::RLWINM8_rec: {
840 "Invalid PPC::RLWINM Instruction!");
848 assert((MEMI < 32 && MESrc < 32 && MBMI < 32 && MBSrc < 32) &&
849 "Invalid PPC::RLWINM Instruction!");
872 bool SrcMaskFull = (MBSrc - MESrc == 1) || (MBSrc == 0 && MESrc == 31);
875 if ((MBMI > MEMI) && !SrcMaskFull)
888 if (SrcMaskFull && (MBSrc - MESrc == 1))
891 APInt RotatedSrcMask = MaskSrc.
rotl(SHMI);
892 APInt FinalMask = RotatedSrcMask & MaskMI;
897 bool Is64Bit = (MI.
getOpcode() == PPC::RLWINM8 ||
911 MI.
setDesc(TII->get(Is64Bit ? PPC::LI8 : PPC::LI));
917 MI.
setDesc(TII->get(Is64Bit ? PPC::ANDI8_rec : PPC::ANDI_rec));
930 NewME) && NewMB <= NewME)|| SrcMaskFull) {
939 uint16_t NewSH = (SHSrc + SHMI) % 32;
961 ++NumRotatesCollapsed;
982 Simplified |= eliminateRedundantTOCSaves(TOCSaves);
985 NumTOCSavesInPrologue++;
988 Simplified |= eliminateRedundantCompare();
1000 static bool isSupportedCmpOp(
unsigned opCode) {
1001 return (opCode == PPC::CMPLD || opCode == PPC::CMPD ||
1002 opCode == PPC::CMPLW || opCode == PPC::CMPW ||
1003 opCode == PPC::CMPLDI || opCode == PPC::CMPDI ||
1004 opCode == PPC::CMPLWI || opCode == PPC::CMPWI);
1007 static bool is64bitCmpOp(
unsigned opCode) {
1008 return (opCode == PPC::CMPLD || opCode == PPC::CMPD ||
1009 opCode == PPC::CMPLDI || opCode == PPC::CMPDI);
1012 static bool isSignedCmpOp(
unsigned opCode) {
1013 return (opCode == PPC::CMPD || opCode == PPC::CMPW ||
1014 opCode == PPC::CMPDI || opCode == PPC::CMPWI);
1017 static unsigned getSignedCmpOpCode(
unsigned opCode) {
1018 if (opCode == PPC::CMPLD)
return PPC::CMPD;
1019 if (opCode == PPC::CMPLW)
return PPC::CMPW;
1020 if (opCode == PPC::CMPLDI)
return PPC::CMPDI;
1021 if (opCode == PPC::CMPLWI)
return PPC::CMPWI;
1029 bool SignedCmp = isSignedCmpOp(CMPI->
getOpcode());
1030 if ((!SignedCmp && Imm == 0) || (SignedCmp && Imm == 0x8000))
1048 bool SignedCmp = isSignedCmpOp(CMPI->
getOpcode());
1049 if ((!SignedCmp && Imm == 0xFFFF) || (SignedCmp && Imm == 0x7FFF))
1064 static unsigned getIncomingRegForBlock(
MachineInstr *Phi,
1080 unsigned SrcReg =
Reg;
1082 unsigned NextReg = SrcReg;
1085 NextReg = getIncomingRegForBlock(Inst, BB1);
1104 auto BII = BB.getFirstInstrTerminator();
1108 if (BB.succ_size() == 2 &&
1109 BII != BB.instr_end() &&
1110 (*BII).getOpcode() == PPC::BCC &&
1111 (*BII).getOperand(1).isReg()) {
1113 Register CndReg = (*BII).getOperand(1).getReg();
1137 return BB.succ_size() == 1;
1140 if (!isEligibleBB(MBB))
1144 if (NumPredBBs == 1) {
1146 if (isEligibleBB(*TmpMBB)) {
1148 MBBtoMoveCmp =
nullptr;
1152 else if (NumPredBBs == 2) {
1160 if (isEligibleBB(*Pred1MBB) && isEligibleForMoveCmp(*Pred2MBB)) {
1165 else if (isEligibleBB(*Pred2MBB) && isEligibleForMoveCmp(*Pred1MBB)) {
1176 for (
int I = 1;
I <= 2;
I++)
1184 MBBtoMoveCmp = Pred2MBB;
1195 bool PPCMIPeephole::eliminateRedundantTOCSaves(
1196 std::map<MachineInstr *, bool> &TOCSaves) {
1197 bool Simplified =
false;
1199 for (
auto TOCSave : TOCSaves) {
1200 if (!TOCSave.second) {
1201 TOCSave.first->eraseFromParent();
1237 bool PPCMIPeephole::eliminateRedundantCompare(
void) {
1238 bool Simplified =
false;
1270 if (!eligibleForCompareElimination(MBB2, MBB1, MBBtoMoveCmp, MRI))
1278 bool IsPartiallyRedundant = (MBBtoMoveCmp !=
nullptr);
1282 if (!isSupportedCmpOp(CMPI1->
getOpcode()) ||
1283 !isSupportedCmpOp(CMPI2->
getOpcode()) ||
1287 unsigned NewOpCode = 0;
1288 unsigned NewPredicate1 = 0, NewPredicate2 = 0;
1289 int16_t Imm1 = 0, NewImm1 = 0, Imm2 = 0, NewImm2 = 0;
1290 bool SwapOperands =
false;
1302 if (!
I->getOperand(2).isImm())
1304 int16_t Imm = (int16_t)
I->getOperand(2).getImm();
1308 if (isEqOrNe(BI2) && !CmpAgainstImmWithSignBit(CMPI2) &&
1311 else if (isEqOrNe(BI1) && !CmpAgainstImmWithSignBit(CMPI1) &&
1321 nullptr,
nullptr,
MRI);
1323 nullptr,
nullptr,
MRI);
1329 if (Cmp1Operand1 == Cmp2Operand1 && Cmp1Operand2 == Cmp2Operand2) {
1332 else if (Cmp1Operand1 == Cmp2Operand2 && Cmp1Operand2 == Cmp2Operand1) {
1339 SwapOperands =
true;
1347 nullptr,
nullptr,
MRI);
1350 if (Cmp1Operand1 != Cmp2Operand1)
1358 if (Imm1 != Imm2 && (!isEqOrNe(BI2) || !isEqOrNe(BI1))) {
1359 int Diff = Imm1 - Imm2;
1360 if (Diff < -2 || Diff > 2)
1363 unsigned PredToInc1 = getPredicateToIncImm(BI1, CMPI1);
1364 unsigned PredToDec1 = getPredicateToDecImm(BI1, CMPI1);
1365 unsigned PredToInc2 = getPredicateToIncImm(BI2, CMPI2);
1366 unsigned PredToDec2 = getPredicateToDecImm(BI2, CMPI2);
1368 if (PredToInc2 && PredToDec1) {
1369 NewPredicate2 = PredToInc2;
1370 NewPredicate1 = PredToDec1;
1375 else if (Diff == 1) {
1378 NewPredicate2 = PredToInc2;
1380 else if (PredToDec1) {
1382 NewPredicate1 = PredToDec1;
1385 else if (Diff == -1) {
1388 NewPredicate2 = PredToDec2;
1390 else if (PredToInc1) {
1392 NewPredicate1 = PredToInc1;
1395 else if (Diff == -2) {
1396 if (PredToDec2 && PredToInc1) {
1397 NewPredicate2 = PredToDec2;
1398 NewPredicate1 = PredToInc1;
1406 if (NewImm2 != NewImm1)
1410 LLVM_DEBUG(
dbgs() <<
"Optimize two pairs of compare and branch:\n");
1417 if (NewOpCode != 0 && NewOpCode != CMPI1->
getOpcode()) {
1418 CMPI1->
setDesc(TII->get(NewOpCode));
1420 if (NewPredicate1) {
1423 if (NewPredicate2) {
1426 if (NewImm1 != Imm1) {
1430 if (IsPartiallyRedundant) {
1439 if (NewImm2 != Imm2)
1442 for (
int I = 1;
I <= 2;
I++) {
1449 "We cannot support if an operand comes from this BB.");
1450 unsigned SrcReg = getIncomingRegForBlock(Inst, MBBtoMoveCmp);
1459 BuildMI(MBB2, MBB2.begin(), DL,
1460 TII->get(PPC::PHI), NewVReg)
1477 if (IsPartiallyRedundant) {
1480 <<
" to handle partial redundancy.\n");
1493 bool PPCMIPeephole::emitRLDICWhenLoweringJumpTables(
MachineInstr &MI) {
1513 uint64_t SHSrc = MOpSHSrc.
getImm();
1514 uint64_t MBSrc = MOpMBSrc.
getImm();
1515 uint64_t SHMI = MOpSHMI.
getImm();
1516 uint64_t MEMI = MOpMEMI.
getImm();
1517 uint64_t NewSH = SHSrc + SHMI;
1518 uint64_t NewMB = MBSrc - SHMI;
1519 if (NewMB > 63 || NewSH > 63)
1528 if ((63 - NewSH) != MEMI)
1535 MI.
setDesc(TII->get(PPC::RLDIC));
1542 NumRotatesCollapsed++;
1557 bool PPCMIPeephole::combineSEXTAndSHL(
MachineInstr &MI,
1569 if (!(MOpSHMI.isImm() && MOpMEMI.
isImm()))
1572 uint64_t SHMI = MOpSHMI.
getImm();
1573 uint64_t MEMI = MOpMEMI.
getImm();
1574 if (SHMI + MEMI != 63)
1593 "EXTSW's second operand should be a register");
1604 : TII->get(PPC::EXTSWSLI_32_64),
1612 ++NumEXTSWAndSLDICombined;
1622 "PowerPC MI Peephole Optimization",
false,
false)
1629 char PPCMIPeephole::ID = 0;
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
uint64_t getZExtValue() const
Get zero extended value.
bool use_nodbg_empty(unsigned RegNo) const
use_nodbg_empty - Return true if there are no non-Debug instructions using the specified register...
MachineBasicBlock * getMBB() const
This class represents lattice values for constants.
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
instr_iterator getFirstInstrTerminator()
Same getFirstTerminator but it ignores bundles and return an instr_iterator instead.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
void initializePPCMIPeepholePass(PassRegistry &)
void setAllBits()
Set every bit to 1.
STATISTIC(NumFunctions, "Total number of functions")
unsigned const TargetRegisterInfo * TRI
static APInt getBitsSetWithWrap(unsigned numBits, unsigned loBit, unsigned hiBit)
Wrap version of getBitsSet.
iterator_range< mop_iterator > operands()
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
void dump() const
dump - Print the current MachineFunction to cerr, useful for debugger use.
bool isSignExtended(const MachineInstr &MI, const unsigned depth=0) const
Return true if the output of the instruction is always a sign-extended, i.e.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
PPCFunctionInfo - This class is derived from MachineFunction private PowerPC target-specific informat...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
unsigned getNumOperands() const
Retuns the total number of operands.
A Use represents the edge between a Value definition and its users.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
INITIALIZE_PASS_BEGIN(PPCMIPeephole, DEBUG_TYPE, "PowerPC MI Peephole Optimization", false, false) INITIALIZE_PASS_END(PPCMIPeephole
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
bool isTOCSaveMI(const MachineInstr &MI) const
static cl::opt< bool > EnableSExtElimination("ppc-eliminate-signext", cl::desc("enable elimination of sign-extensions"), cl::init(false), cl::Hidden)
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)
Initialize the set of available library functions based on the specified target triple.
void setReg(Register Reg)
Change the register this operand corresponds to.
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
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"))
initializer< Ty > init(const Ty &Val)
MachineInstrBundleIterator< MachineInstr > iterator
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
unsigned const MachineRegisterInfo * MRI
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Represent the analysis usage information of a pass.
use_instr_iterator use_instr_begin(unsigned RegNo) const
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
void setImm(int64_t immVal)
FunctionPass class - This class is used to implement most global optimizations.
std::vector< MachineBasicBlock * >::iterator pred_iterator
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
const MachineBasicBlock & front() const
unsigned countLeadingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the most significant bit to the least stopping at the first 1...
pred_iterator pred_begin()
unsigned getPredicateHint(Predicate Opcode)
Return the hint bits of the predicate.
bool isDebugInstr() const
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void setIsKill(bool Val=true)
EXTSWSLI = The PPC extswsli instruction, which does an extend-sign word and shift left immediate...
Predicate getPredicate(unsigned Condition, unsigned Hint)
Return predicate consisting of specified condition and hint bits.
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"))
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
static uint64_t add(uint64_t LeftOp, uint64_t RightOp)
MachineOperand class - Representation of each machine instruction operand.
bool dominates(const MachineDomTreeNode *A, const MachineDomTreeNode *B) const
MachineInstrBuilder MachineInstrBuilder & DefMI
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
APInt rotl(unsigned rotateAmt) const
Rotate left by rotateAmt.
unsigned pred_size() const
const Function & getFunction() const
Return the LLVM function that this machine code represents.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Class for arbitrary precision integers.
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
PowerPC MI Peephole Optimization
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
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 '...
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
static cl::opt< bool > EnableZExtElimination("ppc-eliminate-zeroext", cl::desc("enable elimination of zero-extensions"), cl::init(false), cl::Hidden)
uint64_t getEntryFreq() const
bool hasOneNonDBGUse(unsigned RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug use of the specified register...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
FunctionPass * createPPCMIPeepholePass()
unsigned getPredicateCondition(Predicate Opcode)
Return the condition without hint bits.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isRunOfOnes(unsigned Val, unsigned &MB, unsigned &ME)
Returns true iff Val consists of one contiguous run of 1s with any number of 0s on either side...
MachinePostDominatorTree - an analysis pass wrapper for DominatorTree used to compute the post-domina...
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
void setRegClass(unsigned Reg, const TargetRegisterClass *RC)
setRegClass - Set the register class of the specified virtual register.
void RemoveOperand(unsigned OpNo)
Erase an operand from an instruction, leaving it with one fewer operand than it started with...
bool hasImplicitDef() const
Returns true if the instruction has implicit definition.
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
const PPCRegisterInfo & getRegisterInfo() const
getRegisterInfo - TargetInstrInfo is a superset of MRegister info.
virtual unsigned lookThruCopyLike(unsigned SrcReg, const MachineRegisterInfo *MRI) const
Returns the original SrcReg unless it is the target of a copy-like operation, in which case we chain ...
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
static bool is64Bit(const char *name)
bool convertToImmediateForm(MachineInstr &MI, MachineInstr **KilledDef=nullptr) const
bool isNullValue() const
Determine if all bits are clear.
Wrapper class representing virtual and physical registers.
XXPERMDI - The PPC XXPERMDI instruction.
bool isZeroExtended(const MachineInstr &MI, const unsigned depth=0) const
Return true if the output of the instruction is always zero-extended, i.e.
Predicate getSwappedPredicate(Predicate Opcode)
Assume the condition register is set by MI(a,b), return the predicate if we modify the instructions s...