summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorPuyan Lotfi <puyan@puyan.org>2018-04-05 00:08:15 +0000
committerPuyan Lotfi <puyan@puyan.org>2018-04-05 00:08:15 +0000
commit26c504fe1e066b9a263b8f7d124d0f0d3a30a715 (patch)
treecc5365492e5088e4096d9b41a7f128245f2b9572 /llvm/lib/CodeGen
parent7bd45502fea71ea1e944e8534582c5143f11b52e (diff)
downloadbcm5719-llvm-26c504fe1e066b9a263b8f7d124d0f0d3a30a715.tar.gz
bcm5719-llvm-26c504fe1e066b9a263b8f7d124d0f0d3a30a715.zip
[MIR-Canon] Adding support for multi-def -> user distance reduction.
llvm-svn: 329243
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/MIRCanonicalizerPass.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MIRCanonicalizerPass.cpp b/llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
index bd939fdf104..9ef097c97e7 100644
--- a/llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
+++ b/llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
@@ -189,6 +189,7 @@ static bool rescheduleCanonically(unsigned &PseudoIdempotentInstCount,
Instructions.push_back(&MI);
}
+ std::map<MachineInstr *, std::vector<MachineInstr *>> MultiUsers;
std::vector<MachineInstr *> PseudoIdempotentInstructions;
std::vector<unsigned> PhysRegDefs;
for (auto *II : Instructions) {
@@ -297,10 +298,26 @@ static bool rescheduleCanonically(unsigned &PseudoIdempotentInstCount,
UseI->dump();
});
+ MultiUsers[UseToBringDefCloserTo].push_back(Def);
Changed = true;
MBB->splice(UseI, MBB, DefI);
}
+ // Sort the defs for users of multiple defs lexographically.
+ for (const auto &E : MultiUsers) {
+
+ auto UseI =
+ std::find_if(MBB->instr_begin(), MBB->instr_end(),
+ [&](MachineInstr &MI) -> bool { return &MI == E.first; });
+
+ if (UseI == MBB->instr_end())
+ continue;
+
+ DEBUG(dbgs() << "Rescheduling Multi-Use Instructions Lexographically.";);
+ Changed |= rescheduleLexographically(
+ E.second, MBB, [&]() -> MachineBasicBlock::iterator { return UseI; });
+ }
+
PseudoIdempotentInstCount = PseudoIdempotentInstructions.size();
DEBUG(dbgs() << "Rescheduling Idempotent Instructions Lexographically.";);
Changed |= rescheduleLexographically(
OpenPOWER on IntegriCloud