<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 14, 2015, at 11:26 AM, Eli Bendersky <<a href="mailto:eliben@google.com" class="">eliben@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, May 14, 2015 at 11:01 AM, Matthias Braun <span dir="ltr" class=""><<a href="mailto:matze@braunis.de" target="_blank" class="">matze@braunis.de</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: matze<br class="">
Date: Thu May 14 13:01:13 2015<br class="">
New Revision: 237376<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=237376&view=rev" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=237376&view=rev</a><br class="">
Log:<br class="">
TargetSchedule: factor out common code; NFC<br class="">
<br class="">
Modified:<br class="">
llvm/trunk/include/llvm/CodeGen/TargetSchedule.h<br class="">
llvm/trunk/lib/CodeGen/TargetSchedule.cpp<br class="">
<br class="">
Modified: llvm/trunk/include/llvm/CodeGen/TargetSchedule.h<br class="">
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" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TargetSchedule.h?rev=237376&r1=237375&r2=237376&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/include/llvm/CodeGen/TargetSchedule.h (original)<br class="">
+++ llvm/trunk/include/llvm/CodeGen/TargetSchedule.h Thu May 14 13:01:13 2015<br class="">
@@ -40,6 +40,9 @@ class TargetSchedModel {<br class="">
SmallVector<unsigned, 16> ResourceFactors;<br class="">
unsigned MicroOpFactor; // Multiply to normalize microops to resource units.<br class="">
unsigned ResourceLCM; // Resource units per cycle. Latency normalization factor.<br class="">
+<br class="">
+ unsigned computeInstrLatency(const MCSchedClassDesc &SCDesc) const;<br class="">
+<br class="">
public:<br class="">
TargetSchedModel(): SchedModel(MCSchedModel::GetDefaultSchedModel()), STI(nullptr), TII(nullptr) {}<br class="">
<br class="">
<br class="">
Modified: llvm/trunk/lib/CodeGen/TargetSchedule.cpp<br class="">
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" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetSchedule.cpp?rev=237376&r1=237375&r2=237376&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/lib/CodeGen/TargetSchedule.cpp (original)<br class="">
+++ llvm/trunk/lib/CodeGen/TargetSchedule.cpp Thu May 14 13:01:13 2015<br class="">
@@ -224,6 +224,19 @@ unsigned TargetSchedModel::computeOperan<br class="">
return DefMI->isTransient() ? 0 : TII->defaultDefLatency(SchedModel, DefMI);<br class="">
}<br class="">
<br class="">
+unsigned<br class="">
+TargetSchedModel::computeInstrLatency(const MCSchedClassDesc &SCDesc) const {<br class="">
+ unsigned Latency = 0;<br class="">
+ for (unsigned DefIdx = 0, DefEnd = SCDesc.NumWriteLatencyEntries;<br class="">
+ DefIdx != DefEnd; ++DefIdx) {<br class="">
+ // Lookup the definition's write latency in SubtargetInfo.<br class="">
+ const MCWriteLatencyEntry *WLEntry =<br class="">
+ STI->getWriteLatencyEntry(&SCDesc, DefIdx);<br class="">
+ Latency = std::max(Latency, capLatency(WLEntry->Cycles));<br class="">
+ }<br class="">
+ return Latency;<br class="">
+}<br class="">
+<br class="">
unsigned TargetSchedModel::computeInstrLatency(unsigned Opcode) const {<br class="">
assert(hasInstrSchedModel() && "Only call this function with a SchedModel");<br class="">
<br class="">
@@ -231,16 +244,8 @@ unsigned TargetSchedModel::computeInstrL<br class="">
const MCSchedClassDesc *SCDesc = SchedModel.getSchedClassDesc(SCIdx);<br class="">
unsigned Latency = 0;<br class="">
<br class="">
- if (SCDesc->isValid() && !SCDesc->isVariant()) {<br class="">
- for (unsigned DefIdx = 0, DefEnd = SCDesc->NumWriteLatencyEntries;<br class="">
- DefIdx != DefEnd; ++DefIdx) {<br class="">
- // Lookup the definition's write latency in SubtargetInfo.<br class="">
- const MCWriteLatencyEntry *WLEntry =<br class="">
- STI->getWriteLatencyEntry(SCDesc, DefIdx);<br class="">
- Latency = std::max(Latency, capLatency(WLEntry->Cycles));<br class="">
- }<br class="">
- return Latency;<br class="">
- }<br class="">
+ if (SCDesc->isValid() && !SCDesc->isVariant())<br class="">
+ return computeInstrLatency(*SCDesc);<br class="">
<br class="">
assert(Latency && "No MI sched latency");<br class=""></blockquote><div class=""><br class=""></div><div class="">Hi Mathias,</div><div class=""><br class=""></div><div class="">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></div></div></div></blockquote><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class="">Unless there's another issue here that I'm missing....</div></div></div></div></div></blockquote><div>No I think this is effectively an assert(0), even before my refactoring. I've turned it into an llvm_unreachable.</div><div><br class=""></div><div>- Matthias</div></div></body></html>