23#define DEBUG_TYPE "si-post-ra-bundler"
37 return "SI post-RA bundler";
46class SIPostRABundler {
68char SIPostRABundlerLegacy::
ID = 0;
73 return new SIPostRABundlerLegacy();
76bool SIPostRABundler::isDependentLoad(
const MachineInstr &
MI)
const {
85 if (
TRI->regsOverlap(
Reg, Def))
92void SIPostRABundler::collectUsedRegUnits(
const MachineInstr &
MI,
93 BitVector &UsedRegUnits)
const {
94 if (
MI.isDebugInstr())
97 for (
const MachineOperand &
Op :
MI.operands()) {
98 if (!
Op.isReg() || !
Op.readsReg())
103 "subregister indexes should not be present after RA");
105 for (MCRegUnit Unit :
TRI->regunits(
Reg))
106 UsedRegUnits.
set(
static_cast<unsigned>(Unit));
128bool SIPostRABundler::isBundleCandidate(
const MachineInstr &
MI)
const {
132bool SIPostRABundler::canBundle(
const MachineInstr &
MI,
133 const MachineInstr &NextMI)
const {
137 !isDependentLoad(NextMI);
140bool SIPostRABundlerLegacy::runOnMachineFunction(MachineFunction &MF) {
143 return SIPostRABundler().run(MF);
148 SIPostRABundler().run(MF);
161 unsigned Opc = MI.getOpcode();
162 return Opc == AMDGPU::SCHED_GROUP_BARRIER || Opc == AMDGPU::IGLP_OPT;
173 for (
auto I =
B;
I != E;
I =
Next) {
175 if (!isBundleCandidate(*
I))
180 if (
I->getNumExplicitDefs() != 0)
181 Defs.
insert(
I->defs().begin()->getReg());
185 unsigned ClauseLength = 1;
190 if (canBundle(*BundleEnd, *
I)) {
192 if (
I->getNumExplicitDefs() != 0)
193 Defs.
insert(
I->defs().begin()->getReg());
195 }
else if (!
I->isMetaInstruction() ||
196 I->getOpcode() == AMDGPU::SCHED_BARRIER) {
208 Next = std::next(BundleEnd);
209 if (ClauseLength > 1) {
218 for (
const MachineInstr &BundleMI :
make_range(BundleStart,
Next))
219 collectUsedRegUnits(BundleMI, BundleUsedRegUnits);
221 BundleUsedRegUnits.flip();
225 collectUsedRegUnits(
Kill, KillUsedRegUnits);
227 KillUsedRegUnits &= BundleUsedRegUnits;
233 if (KillUsedRegUnits.none()) {
235 Kill.eraseFromParent();
239 KillUsedRegUnits.reset();
242 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)
This file defines the SmallSet class.
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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
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