<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 14, 2015 at 11:01 AM, Matthias Braun <span dir="ltr"><<a href="mailto:matze@braunis.de" target="_blank">matze@braunis.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: matze<br>
Date: Thu May 14 13:01:13 2015<br>
New Revision: 237376<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=237376&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=237376&view=rev</a><br>
Log:<br>
TargetSchedule: factor out common code; NFC<br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/CodeGen/TargetSchedule.h<br>
    llvm/trunk/lib/CodeGen/TargetSchedule.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/CodeGen/TargetSchedule.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TargetSchedule.h?rev=237376&r1=237375&r2=237376&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TargetSchedule.h?rev=237376&r1=237375&r2=237376&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/CodeGen/TargetSchedule.h (original)<br>
+++ llvm/trunk/include/llvm/CodeGen/TargetSchedule.h Thu May 14 13:01:13 2015<br>
@@ -40,6 +40,9 @@ class TargetSchedModel {<br>
   SmallVector<unsigned, 16> ResourceFactors;<br>
   unsigned MicroOpFactor; // Multiply to normalize microops to resource units.<br>
   unsigned ResourceLCM;   // Resource units per cycle. Latency normalization factor.<br>
+<br>
+  unsigned computeInstrLatency(const MCSchedClassDesc &SCDesc) const;<br>
+<br>
 public:<br>
   TargetSchedModel(): SchedModel(MCSchedModel::GetDefaultSchedModel()), STI(nullptr), TII(nullptr) {}<br>
<br>
<br>
Modified: llvm/trunk/lib/CodeGen/TargetSchedule.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetSchedule.cpp?rev=237376&r1=237375&r2=237376&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetSchedule.cpp?rev=237376&r1=237375&r2=237376&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/TargetSchedule.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/TargetSchedule.cpp Thu May 14 13:01:13 2015<br>
@@ -224,6 +224,19 @@ unsigned TargetSchedModel::computeOperan<br>
   return DefMI->isTransient() ? 0 : TII->defaultDefLatency(SchedModel, DefMI);<br>
 }<br>
<br>
+unsigned<br>
+TargetSchedModel::computeInstrLatency(const MCSchedClassDesc &SCDesc) const {<br>
+  unsigned Latency = 0;<br>
+  for (unsigned DefIdx = 0, DefEnd = SCDesc.NumWriteLatencyEntries;<br>
+       DefIdx != DefEnd; ++DefIdx) {<br>
+    // Lookup the definition's write latency in SubtargetInfo.<br>
+    const MCWriteLatencyEntry *WLEntry =<br>
+      STI->getWriteLatencyEntry(&SCDesc, DefIdx);<br>
+    Latency = std::max(Latency, capLatency(WLEntry->Cycles));<br>
+  }<br>
+  return Latency;<br>
+}<br>
+<br>
 unsigned TargetSchedModel::computeInstrLatency(unsigned Opcode) const {<br>
   assert(hasInstrSchedModel() && "Only call this function with a SchedModel");<br>
<br>
@@ -231,16 +244,8 @@ unsigned TargetSchedModel::computeInstrL<br>
   const MCSchedClassDesc *SCDesc = SchedModel.getSchedClassDesc(SCIdx);<br>
   unsigned Latency = 0;<br>
<br>
-  if (SCDesc->isValid() && !SCDesc->isVariant()) {<br>
-    for (unsigned DefIdx = 0, DefEnd = SCDesc->NumWriteLatencyEntries;<br>
-         DefIdx != DefEnd; ++DefIdx) {<br>
-      // Lookup the definition's write latency in SubtargetInfo.<br>
-      const MCWriteLatencyEntry *WLEntry =<br>
-          STI->getWriteLatencyEntry(SCDesc, DefIdx);<br>
-      Latency = std::max(Latency, capLatency(WLEntry->Cycles));<br>
-    }<br>
-    return Latency;<br>
-  }<br>
+  if (SCDesc->isValid() && !SCDesc->isVariant())<br>
+    return computeInstrLatency(*SCDesc);<br>
<br>
   assert(Latency && "No MI sched latency");<br></blockquote><div><br></div><div>Hi Mathias,</div><div><br></div><div>This leaves this assert in a weird state, since Latency is not modified from its initialized value of 0. So the assert will always fire. In this case, it should be modified accordingly and Latency removed. </div><div><br></div><div>Unless there's another issue here that I'm missing....</div><div><br></div><div>Eli</div><div><br></div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
   return 0;<br>
@@ -257,17 +262,8 @@ TargetSchedModel::computeInstrLatency(co<br>
<br>
   if (hasInstrSchedModel()) {<br>
     const MCSchedClassDesc *SCDesc = resolveSchedClass(MI);<br>
-    if (SCDesc->isValid()) {<br>
-      unsigned Latency = 0;<br>
-      for (unsigned DefIdx = 0, DefEnd = SCDesc->NumWriteLatencyEntries;<br>
-           DefIdx != DefEnd; ++DefIdx) {<br>
-        // Lookup the definition's write latency in SubtargetInfo.<br>
-        const MCWriteLatencyEntry *WLEntry =<br>
-          STI->getWriteLatencyEntry(SCDesc, DefIdx);<br>
-        Latency = std::max(Latency, capLatency(WLEntry->Cycles));<br>
-      }<br>
-      return Latency;<br>
-    }<br>
+    if (SCDesc->isValid())<br>
+      return computeInstrLatency(*SCDesc);<br>
   }<br>
   return TII->defaultDefLatency(SchedModel, MI);<br>
 }<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>