22#define DEBUG_TYPE "si-post-ra-bundler"
36 return "SI post-RA bundler";
45class SIPostRABundler {
67char SIPostRABundlerLegacy::ID = 0;
72 return new SIPostRABundlerLegacy();
75bool SIPostRABundler::isDependentLoad(
const MachineInstr &
MI)
const {
84 if (
TRI->regsOverlap(
Reg, Def))
91void SIPostRABundler::collectUsedRegUnits(
const MachineInstr &
MI,
92 BitVector &UsedRegUnits)
const {
93 if (
MI.isDebugInstr())
96 for (
const MachineOperand &
Op :
MI.operands()) {
97 if (!
Op.isReg() || !
Op.readsReg())
102 "subregister indexes should not be present after RA");
104 for (MCRegUnit Unit :
TRI->regunits(
Reg))
105 UsedRegUnits.
set(
static_cast<unsigned>(Unit));
127bool SIPostRABundler::isBundleCandidate(
const MachineInstr &
MI)
const {
131bool SIPostRABundler::canBundle(
const MachineInstr &
MI,
132 const MachineInstr &NextMI)
const {
136 !isDependentLoad(NextMI);
142 return SIPostRABundler().run(MF);
147 SIPostRABundler().run(MF);
160 unsigned Opc = MI.getOpcode();
161 return Opc == AMDGPU::SCHED_GROUP_BARRIER || Opc == AMDGPU::IGLP_OPT;
172 for (
auto I =
B;
I != E;
I =
Next) {
174 if (!isBundleCandidate(*
I))
179 if (
I->getNumExplicitDefs() != 0)
180 Defs.
insert(
I->defs().begin()->getReg());
184 unsigned ClauseLength = 1;
189 if (canBundle(*BundleEnd, *
I)) {
191 if (
I->getNumExplicitDefs() != 0)
192 Defs.
insert(
I->defs().begin()->getReg());
194 }
else if (!
I->isMetaInstruction() ||
195 I->getOpcode() == AMDGPU::SCHED_BARRIER) {
207 Next = std::next(BundleEnd);
208 if (ClauseLength > 1) {
217 for (
const MachineInstr &BundleMI :
make_range(BundleStart,
Next))
218 collectUsedRegUnits(BundleMI, BundleUsedRegUnits);
220 BundleUsedRegUnits.flip();
224 collectUsedRegUnits(
Kill, KillUsedRegUnits);
226 KillUsedRegUnits &= BundleUsedRegUnits;
232 if (KillUsedRegUnits.none()) {
234 Kill.eraseFromParent();
238 KillUsedRegUnits.reset();
241 BundleUsedRegUnits.reset();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
AMD GCN specific subclass of TargetSubtarget.
Register const TargetRegisterInfo * TRI
Promote Memory to Register
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static bool hasSameMemFormat(const MachineInstr &A, const MachineInstr &B)
static bool isMemoryInst(const MachineInstr &MI)
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
BitVector & set()
Set all bits in the bitvector.
FunctionPass class - This class is used to implement most global optimizations.
Instructions::iterator instr_iterator
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.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
bool isBundled() const
Return true if this instruction part of a bundle.
MachineOperand class - Representation of each machine instruction operand.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Wrapper class representing virtual and physical registers.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
Represent a constant reference to a string, i.e.
constexpr bool isFLAT(const T &...O)
constexpr bool isMTBUF(const T &...O)
constexpr bool isVIMAGE(const T &...O)
constexpr bool isSMRD(const T &...O)
constexpr bool isMIMG(const T &...O)
constexpr bool isMUBUF(const T &...O)
constexpr bool isVSAMPLE(const T &...O)
constexpr bool isDS(const T &...O)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void finalizeBundle(MachineBasicBlock &MBB, MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
finalizeBundle - Finalize a machine instruction bundle which includes a sequence of instructions star...
@ Kill
The last use of a register.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
FunctionPass * createSIPostRABundlerPass()
char & SIPostRABundlerLegacyID
DWARFExpression::Operation Op
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next