[PATCH] D23510: MachineScheduler: Restore TopCand after comparing top and bottom candidates

Tom Stellard via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 15 08:14:55 PDT 2016


tstellarAMD created this revision.
tstellarAMD added a reviewer: MatzeB.
tstellarAMD added a subscriber: llvm-commits.
Herald added a subscriber: MatzeB.

In the GenericScheduler, before comparing top and bottom candidates, we set
TopCand.Reason to NoCand, so that we can determine wether or not it was selected
over BotCand.  However, in the case where the bottom candidate is selected,
TopCand needs to have Reason restored to its original value, otherwise
the scheduler will continue selecting from the bottom, until a new
instruction is added to the Top queue.

https://reviews.llvm.org/D23510

Files:
  lib/CodeGen/MachineScheduler.cpp

Index: lib/CodeGen/MachineScheduler.cpp
===================================================================
--- lib/CodeGen/MachineScheduler.cpp
+++ lib/CodeGen/MachineScheduler.cpp
@@ -3000,12 +3000,15 @@
   assert(BotCand.isValid());
   assert(TopCand.isValid());
   SchedCandidate Cand = BotCand;
+  GenericSchedulerBase::CandReason TopReason = TopCand.Reason;
   TopCand.Reason = NoCand;
   tryCandidate(Cand, TopCand, nullptr);
   if (TopCand.Reason != NoCand) {
     Cand.setBest(TopCand);
     DEBUG(traceCandidate(Cand));
-  }
+  } else
+    // Restore the original Reason for TopCand if it isn't selected.
+    TopCand.Reason = TopReason;
 
   IsTopNode = Cand.AtTop;
   tracePick(Cand);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23510.68038.patch
Type: text/x-patch
Size: 697 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160815/23a20a73/attachment.bin>


More information about the llvm-commits mailing list