40 unsigned Opc =
MI->getOpcode();
42 case TargetOpcode::COPY: {
45 RegisterRef DstR = DFG.makeRegRef(Dst.getReg(), Dst.getSubReg());
46 RegisterRef SrcR = DFG.makeRegRef(Src.getReg(), Src.getSubReg());
50 if (
TRI.getMinimalPhysRegClass(DstR.
Reg) !=
51 TRI.getMinimalPhysRegClass(SrcR.
Reg))
53 if (!DFG.isTracked(SrcR) || !DFG.isTracked(DstR))
55 EM.insert(std::make_pair(DstR, SrcR));
58 case TargetOpcode::REG_SEQUENCE:
65 CopyMap.insert(std::make_pair(SA.
Id, EM));
69 auto FS = DefM.find(
I.second.Reg);
70 if (FS == DefM.end() || FS->second.empty())
72 RDefMap[
I.second][SA.
Id] = FS->second.top()->Id;
82 RRs.insert(
RA.Addr->getRegRef(DFG));
84 for (
auto &R : RDefMap) {
85 if (!RRs.count(R.first))
93 for (
auto &R : RDefMap) {
94 if (!RRs.count(
R.first))
96 auto F = DefM.find(
R.first.Reg);
97 if (
F == DefM.end() ||
F->second.empty())
99 R.second[
IA.Id] =
F->second.top()->Id;
104 bool Changed =
false;
106 DFG.markBlock(BA.
Id, DefM);
111 EqualityMap EM(std::less<RegisterRef>(DFG.getPRI()));
112 if (interpretAsCopy(SA.
Addr->getCode(), EM))
117 DFG.pushAllDefs(IA, DefM);
122 Changed |= scanBlock(
I->getBlock());
124 DFG.releaseBlock(BA.
Id, DefM);
128bool CopyPropagation::run() {
129 scanBlock(&DFG.getMF().front());
132 dbgs() <<
"Copies:\n";
136 if (CopyMap.count(
I)) {
137 for (
auto J : CopyMap.at(
I))
143 dbgs() <<
"\nRDef map:\n";
144 for (
auto R : RDefMap) {
146 for (
auto &M : R.second)
153 bool Changed =
false;
155 bool HasLimit =
CpLimit.getNumOccurrences() > 0;
158 auto MinPhysReg = [
this] (
RegisterRef RR) ->
unsigned {
164 if (RR.Mask ==
TRI.getSubRegIndexLaneMask(S.getSubRegIndex()))
165 return S.getSubReg();
178 auto FS = CopyMap.find(SA.
Id);
179 if (FS == CopyMap.end())
185 auto FR = EM.find(DR);
192 auto &RDefSR = RDefMap[SR];
195 for (
NodeId N = DA.Addr->getReachedUse(), NextN;
N;
N = NextN) {
201 if (!PRI.
equal_to(UA.Addr->getRegRef(DFG), DR))
206 if (RDefSR[IA.Id] != RDefSR_SA)
218 unsigned NewReg = MinPhysReg(SR);
221 DFG.unlinkUse(UA,
false);
222 if (RDefSR_SA != 0) {
223 UA.Addr->linkToDef(UA.Id, DFG.addr<
DefNode*>(RDefSR_SA));
225 UA.Addr->setReachingDef(0);
226 UA.Addr->setSibling(0);
236 auto FC = CopyMap.find(IA.Id);
237 if (FC != CopyMap.end()) {
239 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