31 #define DEBUG_TYPE "ppc-pre-emit-peephole" 34 "Number of r+r instructions converted to r+i in pre-emit peephole");
36 "Number of instructions deleted in pre-emit peephole");
38 "Number of self copy instructions eliminated");
42 cl::desc(
"Run pre-emit peephole optimizations."));
70 unsigned Opc =
MI.getOpcode();
75 MI.getOperand(0).getReg() ==
MI.getOperand(1).getReg() &&
76 MI.getOperand(0).getReg() ==
MI.getOperand(2).getReg()) {
84 MI.getOperand(0).getReg() ==
MI.getOperand(1).getReg()) {
95 NumRRConvertedInPreEmit++;
108 auto I = MBB.getFirstInstrTerminator();
109 if (
I == MBB.instr_end())
117 bool SeenUse =
false;
119 for (It++; It != Er; It++) {
120 if (It->modifiesRegister(CRBit, TRI)) {
121 if ((It->getOpcode() == PPC::CRUNSET ||
122 It->getOpcode() == PPC::CRSET) &&
123 It->getOperand(0).getReg() == CRBit)
127 if (It->readsRegister(CRBit, TRI))
130 if (!CRSetMI)
continue;
133 if ((Br->
getOpcode() == PPC::BCn && CRSetOp == PPC::CRSET) ||
134 (Br->
getOpcode() == PPC::BC && CRSetOp == PPC::CRUNSET)) {
143 for (; It != Er; It++) {
144 if (It->isDebugInstr())
continue;
145 assert(It->isTerminator() &&
"Non-terminator after a terminator");
153 for (
auto &Succ : MBB.successors())
155 MBB.removeSuccessor(Succ);
164 for (
auto &SuccMBB : MBB.successors())
165 if (SuccMBB->isLiveIn(CRBit) || SuccMBB->isLiveIn(CRReg)) {
174 LLVM_DEBUG(
dbgs() <<
"PPC pre-emit peephole: erasing instruction: ");
176 MI->eraseFromParent();
177 NumRemovedInPreEmit++;
186 char PPCPreEmitPeephole::ID = 0;
189 return new PPCPreEmitPeephole();
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
MachineBasicBlock * getMBB() const
This class represents lattice values for constants.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
void push_back(const T &Elt)
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
Describe properties that are true of each instruction in the target description file.
unsigned getReg() const
getReg - Returns the register number.
STATISTIC(NumFunctions, "Total number of functions")
unsigned const TargetRegisterInfo * TRI
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
const HexagonInstrInfo * TII
MachineBasicBlock iterator that automatically skips over MIs that are inside bundles (i...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
initializer< Ty > init(const Ty &Val)
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.
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
static bool isSameClassPhysRegCopy(unsigned Opcode)
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
static unsigned getCRFromCRBit(unsigned SrcReg)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
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.
MachineFunctionProperties & set(Property P)
Representation of each machine instruction.
void initializePPCPreEmitPeepholePass(PassRegistry &)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
FunctionPass * createPPCPreEmitPeepholePass()
static cl::opt< bool > RunPreEmitPeephole("ppc-late-peephole", cl::Hidden, cl::init(true), cl::desc("Run pre-emit peephole optimizations."))
const MachineOperand & getOperand(unsigned i) const
bool convertToImmediateForm(MachineInstr &MI, MachineInstr **KilledDef=nullptr) const
Properties which a MachineFunction may have at a given point in time.