[llvm] r326880 - [SystemZ] Improve getCurrCycleIdx() in SystemZHazardRecognizer.

Jonas Paulsson via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 7 00:54:32 PST 2018


Author: jonpa
Date: Wed Mar  7 00:54:32 2018
New Revision: 326880

URL: http://llvm.org/viewvc/llvm-project?rev=326880&view=rev
Log:
[SystemZ]  Improve getCurrCycleIdx() in SystemZHazardRecognizer.

getCurrCycleIdx() returns the decoder cycle index which the next candidate SU
will be placed on.

This patch improves this method by passing the candidate SU to it so that if
SU will begin a new group, the index of that group is returned instead.

Review: Ulrich Weigand

Modified:
    llvm/trunk/lib/Target/SystemZ/SystemZHazardRecognizer.cpp
    llvm/trunk/lib/Target/SystemZ/SystemZHazardRecognizer.h

Modified: llvm/trunk/lib/Target/SystemZ/SystemZHazardRecognizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZHazardRecognizer.cpp?rev=326880&r1=326879&r2=326880&view=diff
==============================================================================
--- llvm/trunk/lib/Target/SystemZ/SystemZHazardRecognizer.cpp (original)
+++ llvm/trunk/lib/Target/SystemZ/SystemZHazardRecognizer.cpp Wed Mar  7 00:54:32 2018
@@ -59,10 +59,18 @@ getNumDecoderSlots(SUnit *SU) const {
   return 1; // Normal instruction
 }
 
-unsigned SystemZHazardRecognizer::getCurrCycleIdx() const {
+unsigned SystemZHazardRecognizer::getCurrCycleIdx(SUnit *SU) const {
   unsigned Idx = CurrGroupSize;
   if (GrpCount % 2)
     Idx += 3;
+
+  if (SU != nullptr && !fitsIntoCurrentGroup(SU)) {
+    if (Idx == 1 || Idx == 2)
+      Idx = 3;
+    else if (Idx == 4 || Idx == 5)
+      Idx = 0;
+  }
+
   return Idx;
 }
 
@@ -278,7 +286,7 @@ EmitInstruction(SUnit *SU) {
 
   // Make note of an instruction that uses a blocking resource (FPd).
   if (SU->isUnbuffered) {
-    LastFPdOpCycleIdx = getCurrCycleIdx();
+    LastFPdOpCycleIdx = getCurrCycleIdx(SU);
     DEBUG(dbgs() << "++ Last FPd cycle index: "
           << LastFPdOpCycleIdx << "\n";);
   }
@@ -321,7 +329,7 @@ int SystemZHazardRecognizer::groupingCos
   return 0;
 }
 
-bool SystemZHazardRecognizer::isFPdOpPreferred_distance(const SUnit *SU) {
+bool SystemZHazardRecognizer::isFPdOpPreferred_distance(SUnit *SU) const {
   assert (SU->isUnbuffered);
   // If this is the first FPd op, it should be scheduled high.
   if (LastFPdOpCycleIdx == UINT_MAX)
@@ -330,9 +338,10 @@ bool SystemZHazardRecognizer::isFPdOpPre
   // of the processor to use the other FPd unit there. This should
   // generally happen if two FPd ops are placed with 2 other
   // instructions between them (modulo 6).
-  if (LastFPdOpCycleIdx > getCurrCycleIdx())
-    return ((LastFPdOpCycleIdx - getCurrCycleIdx()) == 3);
-  return ((getCurrCycleIdx() - LastFPdOpCycleIdx) == 3);
+  unsigned SUCycleIdx = getCurrCycleIdx(SU);
+  if (LastFPdOpCycleIdx > SUCycleIdx)
+    return ((LastFPdOpCycleIdx - SUCycleIdx) == 3);
+  return ((SUCycleIdx - LastFPdOpCycleIdx) == 3);
 }
 
 int SystemZHazardRecognizer::

Modified: llvm/trunk/lib/Target/SystemZ/SystemZHazardRecognizer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZHazardRecognizer.h?rev=326880&r1=326879&r2=326880&view=diff
==============================================================================
--- llvm/trunk/lib/Target/SystemZ/SystemZHazardRecognizer.h (original)
+++ llvm/trunk/lib/Target/SystemZ/SystemZHazardRecognizer.h Wed Mar  7 00:54:32 2018
@@ -75,8 +75,10 @@ class SystemZHazardRecognizer : public S
 
   /// Two decoder groups per cycle are formed (for z13), meaning 2x3
   /// instructions. This function returns a number between 0 and 5,
-  /// representing the current decoder slot of the current cycle.
-  unsigned getCurrCycleIdx() const;
+  /// representing the current decoder slot of the current cycle.  If an SU
+  /// is passed which will begin a new decoder group, the returned value is
+  /// the cycle index of the next group.
+  unsigned getCurrCycleIdx(SUnit *SU = nullptr) const;
 
   /// LastFPdOpCycleIdx stores the numbeer returned by getCurrCycleIdx()
   /// when a stalling operation is scheduled (which uses the FPd resource).
@@ -95,7 +97,7 @@ class SystemZHazardRecognizer : public S
 
   /// With the goal of alternating processor sides for stalling (FPd)
   /// ops, return true if it seems good to schedule an FPd op next.
-  bool isFPdOpPreferred_distance(const SUnit *SU);
+  bool isFPdOpPreferred_distance(SUnit *SU) const;
 
   /// Last emitted instruction or nullptr.
   MachineInstr *LastEmittedMI;




More information about the llvm-commits mailing list