41 unsigned Opc =
MI->getOpcode();
43 case TargetOpcode::COPY: {
46 RegisterRef DstR = DFG.makeRegRef(Dst.getReg(), Dst.getSubReg());
47 RegisterRef SrcR = DFG.makeRegRef(Src.getReg(), Src.getSubReg());
51 if (
TRI.getMinimalPhysRegClass(DstR.
Reg) !=
52 TRI.getMinimalPhysRegClass(SrcR.
Reg))
54 if (!DFG.isTracked(SrcR) || !DFG.isTracked(DstR))
56 EM.insert(std::make_pair(DstR, SrcR));
59 case TargetOpcode::REG_SEQUENCE:
66 CopyMap.insert(std::make_pair(SA.
Id, EM));
70 auto FS = DefM.find(
I.second.Reg);
71 if (FS == DefM.end() || FS->second.empty())
73 RDefMap[
I.second][SA.
Id] = FS->second.top()->Id;
83 RRs.insert(
RA.Addr->getRegRef(DFG));
85 for (
auto &R : RDefMap) {
86 if (!RRs.count(R.first))
94 for (
auto &R : RDefMap) {
95 if (!RRs.count(
R.first))
97 auto F = DefM.find(
R.first.Reg);
98 if (
F == DefM.end() ||
F->second.empty())
100 R.second[
IA.Id] =
F->second.top()->Id;
105 bool Changed =
false;
107 DFG.markBlock(BA.
Id, DefM);
112 EqualityMap EM(std::less<RegisterRef>(DFG.getPRI()));
113 if (interpretAsCopy(SA.
Addr->getCode(), EM))
118 DFG.pushAllDefs(IA, DefM);
123 Changed |= scanBlock(
I->getBlock());
125 DFG.releaseBlock(BA.
Id, DefM);
129bool CopyPropagation::run() {
130 scanBlock(&DFG.getMF().front());
133 dbgs() <<
"Copies:\n";
137 if (CopyMap.count(
I)) {
138 for (
auto J : CopyMap.at(
I))
144 dbgs() <<
"\nRDef map:\n";
145 for (
auto R : RDefMap) {
147 for (
auto &M : R.second)
154 bool Changed =
false;
156 bool HasLimit =
CpLimit.getNumOccurrences() > 0;
159 auto MinPhysReg = [
this] (
RegisterRef RR) ->
unsigned {
165 if (RR.Mask ==
TRI.getSubRegIndexLaneMask(S.getSubRegIndex()))
166 return S.getSubReg();
179 auto FS = CopyMap.find(SA.
Id);
180 if (FS == CopyMap.end())
186 auto FR = EM.find(DR);
193 auto &RDefSR = RDefMap[SR];
196 for (
NodeId N = DA.Addr->getReachedUse(), NextN;
N;
N = NextN) {
202 if (!PRI.
equal_to(UA.Addr->getRegRef(DFG), DR))
207 if (RDefSR[IA.Id] != RDefSR_SA)
219 unsigned NewReg = MinPhysReg(SR);
222 DFG.unlinkUse(UA,
false);
223 if (RDefSR_SA != 0) {
224 UA.Addr->linkToDef(UA.Id, DFG.addr<
DefNode*>(RDefSR_SA));
226 UA.Addr->setReachingDef(0);
227 UA.Addr->setSibling(0);
237 auto FC = CopyMap.find(IA.Id);
238 if (FC != CopyMap.end()) {
240 auto &M = FC->second;
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
unsigned const TargetRegisterInfo * TRI
static cl::opt< unsigned > CpLimit("rdf-cp-limit", cl::init(0), cl::Hidden)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SI optimize exec mask operations pre RA
This class represents an Operation in the Expression.
Base class for the actual dominator tree node.
Iterator that enumerates the sub-registers of a Reg and the associated sub-register indices.
bool isValid() const
Returns true if this iterator is not yet at the end.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
static constexpr bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
const LaneBitmask LaneMask
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
initializer< Ty > init(const Ty &Val)
std::set< RegisterRef > RegisterSet
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
std::map< RegisterRef, RegisterRef > EqualityMap
bool equal_to(RegisterRef A, RegisterRef B) const
NodeId getSibling() const