misched: Allow disabling scoreboard hazard checking for subtargets with a
authorAndrew Trick <atrick@apple.com>
Tue, 5 Jun 2012 03:44:32 +0000 (03:44 +0000)
committerAndrew Trick <atrick@apple.com>
Tue, 5 Jun 2012 03:44:32 +0000 (03:44 +0000)
valid itinerary but no pipeline stages.

An itinerary can contain useful scheduling information without specifying pipeline stages for each instruction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157977 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/ScheduleHazardRecognizer.h
lib/CodeGen/ScoreboardHazardRecognizer.cpp

index fd62841918cbbab69baff0c0d010e98f41947007..9dfa3446ef50fe33fa30eee80324d4fba71bfc0e 100644 (file)
@@ -46,6 +46,8 @@ public:
 
   /// atIssueLimit - Return true if no more instructions may be issued in this
   /// cycle.
+  ///
+  /// FIXME: remove this once MachineScheduler is the only client.
   virtual bool atIssueLimit() const { return false; }
 
   /// getHazardType - Return the hazard type of emitting this node.  There are
index f3bad9431935c11170475b891e46a2fbc0b06f44..ac62d7ef0d47eb3703f2c29ec62f140df8a23b47 100644 (file)
@@ -39,9 +39,9 @@ ScoreboardHazardRecognizer(const InstrItineraryData *II,
   DebugType = ParentDebugType;
 #endif
 
-  // Determine the maximum depth of any itinerary. This determines the
-  // depth of the scoreboard. We always make the scoreboard at least 1
-  // cycle deep to avoid dealing with the boundary condition.
+  // Determine the maximum depth of any itinerary. This determines the depth of
+  // the scoreboard. We always make the scoreboard at least 1 cycle deep to
+  // avoid dealing with the boundary condition.
   unsigned ScoreboardDepth = 1;
   if (ItinData && !ItinData->isEmpty()) {
     IssueWidth = ItinData->IssueWidth;
@@ -63,16 +63,22 @@ ScoreboardHazardRecognizer(const InstrItineraryData *II,
       // Find the next power-of-2 >= ItinDepth
       while (ItinDepth > ScoreboardDepth) {
         ScoreboardDepth *= 2;
+        // Don't set MaxLookAhead until we find at least one nonzero stage.
+        // This way, an itinerary with no stages has MaxLookAhead==0, which
+        // completely bypasses the scoreboard hazard logic.
+        MaxLookAhead = ScoreboardDepth;
       }
     }
-    MaxLookAhead = ScoreboardDepth;
   }
 
   ReservedScoreboard.reset(ScoreboardDepth);
   RequiredScoreboard.reset(ScoreboardDepth);
 
-  DEBUG(dbgs() << "Using scoreboard hazard recognizer: Depth = "
-               << ScoreboardDepth << '\n');
+  if (!MaxLookAhead)
+    DEBUG(dbgs() << "Disabled scoreboard hazard recognizer\n");
+  else
+    DEBUG(dbgs() << "Using scoreboard hazard recognizer: Depth = "
+          << ScoreboardDepth << '\n');
 }
 
 void ScoreboardHazardRecognizer::Reset() {