summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/Hexagon/HexagonHazardRecognizer.cpp16
-rw-r--r--llvm/lib/Target/Hexagon/HexagonHazardRecognizer.h2
2 files changed, 14 insertions, 4 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonHazardRecognizer.cpp b/llvm/lib/Target/Hexagon/HexagonHazardRecognizer.cpp
index 036b1867870..cae7318077b 100644
--- a/llvm/lib/Target/Hexagon/HexagonHazardRecognizer.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonHazardRecognizer.cpp
@@ -31,6 +31,7 @@ void HexagonHazardRecognizer::Reset() {
PacketNum = 0;
UsesDotCur = nullptr;
DotCurPNum = -1;
+ UsesLoad = false;
RegDefs.clear();
}
@@ -78,15 +79,20 @@ void HexagonHazardRecognizer::AdvanceCycle() {
UsesDotCur = nullptr;
DotCurPNum = -1;
}
+ UsesLoad = false;
PacketNum++;
RegDefs.clear();
}
-/// If a packet contains a dot cur instruction, then we may prefer the
-/// instruction that can use the dot cur result. Or, if the use
-/// isn't scheduled in the same packet, then prefer other instructions
-/// in the subsequent packet.
+/// Handle the cases when we prefer one instruction over another. Case 1 - we
+/// prefer not to generate multiple loads in the packet to avoid a potential
+/// bank conflict. Case 2 - if a packet contains a dot cur instruction, then we
+/// prefer the instruction that can use the dot cur result. However, if the use
+/// is not scheduled in the same packet, then prefer other instructions in the
+/// subsequent packet.
bool HexagonHazardRecognizer::ShouldPreferAnother(SUnit *SU) {
+ if (UsesLoad && SU->isInstr() && SU->getInstr()->mayLoad())
+ return true;
return UsesDotCur && ((SU == UsesDotCur) ^ (DotCurPNum == (int)PacketNum));
}
@@ -137,4 +143,6 @@ void HexagonHazardRecognizer::EmitInstruction(SUnit *SU) {
UsesDotCur = nullptr;
DotCurPNum = -1;
}
+
+ UsesLoad = MI->mayLoad();
}
diff --git a/llvm/lib/Target/Hexagon/HexagonHazardRecognizer.h b/llvm/lib/Target/Hexagon/HexagonHazardRecognizer.h
index 70efcb7a9f7..f904b05abd5 100644
--- a/llvm/lib/Target/Hexagon/HexagonHazardRecognizer.h
+++ b/llvm/lib/Target/Hexagon/HexagonHazardRecognizer.h
@@ -30,6 +30,8 @@ class HexagonHazardRecognizer : public ScheduleHazardRecognizer {
// The packet number when a dor cur is emitted. If its use is not generated
// in the same packet, then try to wait another cycle before emitting.
int DotCurPNum;
+ // Does the packet contain a load. Used to restrict another load, if possible.
+ bool UsesLoad = false;
// The set of registers defined by instructions in the current packet.
SmallSet<unsigned, 8> RegDefs;
OpenPOWER on IntegriCloud