[llvm] r324250 - [Hexagon] Memoize instruction positions in BitTracker
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 5 09:12:07 PST 2018
Author: kparzysz
Date: Mon Feb 5 09:12:07 2018
New Revision: 324250
URL: http://llvm.org/viewvc/llvm-project?rev=324250&view=rev
Log:
[Hexagon] Memoize instruction positions in BitTracker
Modified:
llvm/trunk/lib/Target/Hexagon/BitTracker.cpp
llvm/trunk/lib/Target/Hexagon/BitTracker.h
Modified: llvm/trunk/lib/Target/Hexagon/BitTracker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/BitTracker.cpp?rev=324250&r1=324249&r2=324250&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/BitTracker.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/BitTracker.cpp Mon Feb 5 09:12:07 2018
@@ -779,15 +779,18 @@ bool BT::UseQueueType::Cmp::operator()(c
return BA->getNumber() > BB->getNumber();
}
- MachineBasicBlock::const_iterator ItA = InstA->getIterator();
- MachineBasicBlock::const_iterator ItB = InstB->getIterator();
- MachineBasicBlock::const_iterator End = BA->end();
- while (ItA != End) {
- if (ItA == ItB)
- return false; // ItA was before ItB.
- ++ItA;
- }
- return true;
+ auto getDist = [this] (const MachineInstr *MI) {
+ auto F = Dist.find(MI);
+ if (F != Dist.end())
+ return F->second;
+ MachineBasicBlock::const_iterator I = MI->getParent()->begin();
+ MachineBasicBlock::const_iterator E = MI->getIterator();
+ unsigned D = std::distance(I, E);
+ Dist.insert(std::make_pair(MI, D));
+ return D;
+ };
+
+ return getDist(InstA) > getDist(InstB);
}
// Main W-Z implementation.
@@ -1138,6 +1141,7 @@ void BT::run() {
runEdgeQueue(BlockScanned);
runUseQueue();
}
+ UseQ.reset();
if (Trace)
print_cells(dbgs() << "Cells after propagation:\n");
Modified: llvm/trunk/lib/Target/Hexagon/BitTracker.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/BitTracker.h?rev=324250&r1=324249&r2=324250&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/BitTracker.h (original)
+++ llvm/trunk/lib/Target/Hexagon/BitTracker.h Mon Feb 5 09:12:07 2018
@@ -73,6 +73,8 @@ private:
// Priority queue of instructions using modified registers, ordered by
// their relative position in a basic block.
struct UseQueueType {
+ UseQueueType() : Uses(Dist) {}
+
unsigned size() const {
return Uses.size();
}
@@ -90,12 +92,18 @@ private:
Set.erase(front());
Uses.pop();
}
+ void reset() {
+ Dist.clear();
+ }
private:
struct Cmp {
+ Cmp(DenseMap<const MachineInstr*,unsigned> &Map) : Dist(Map) {}
bool operator()(const MachineInstr *MI, const MachineInstr *MJ) const;
+ DenseMap<const MachineInstr*,unsigned> &Dist;
};
std::priority_queue<MachineInstr*, std::vector<MachineInstr*>, Cmp> Uses;
- DenseSet<MachineInstr*> Set; // Set to avoid adding duplicate entries.
+ DenseSet<const MachineInstr*> Set; // Set to avoid adding duplicate entries.
+ DenseMap<const MachineInstr*,unsigned> Dist;
};
void reset();
More information about the llvm-commits
mailing list