diff options
author | Andrew V. Tischenko <andrew.v.tischenko@gmail.com> | 2017-07-26 18:55:14 +0000 |
---|---|---|
committer | Andrew V. Tischenko <andrew.v.tischenko@gmail.com> | 2017-07-26 18:55:14 +0000 |
commit | d1fefa3d7cfebb468a2280b73895cd1e2ad70e82 (patch) | |
tree | 0ed8823df47c4b0e56c10eb2b6d0eecd1139a149 /llvm/lib/CodeGen/TargetSchedule.cpp | |
parent | 7d7f0dc08b5124d1af9818e2841eeb000eaf9624 (diff) | |
download | bcm5719-llvm-d1fefa3d7cfebb468a2280b73895cd1e2ad70e82.tar.gz bcm5719-llvm-d1fefa3d7cfebb468a2280b73895cd1e2ad70e82.zip |
This patch returns proper value to indicate the case when instruction throughput can't be calculated.
Differential revision https://reviews.llvm.org/D35831
llvm-svn: 309156
Diffstat (limited to 'llvm/lib/CodeGen/TargetSchedule.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetSchedule.cpp | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/llvm/lib/CodeGen/TargetSchedule.cpp b/llvm/lib/CodeGen/TargetSchedule.cpp index 9210ea8a83f..e1f7edc627b 100644 --- a/llvm/lib/CodeGen/TargetSchedule.cpp +++ b/llvm/lib/CodeGen/TargetSchedule.cpp @@ -339,42 +339,46 @@ computeOutputLatency(const MachineInstr *DefMI, unsigned DefOperIdx, static Optional<double> getRThroughputFromItineraries(unsigned schedClass, const InstrItineraryData *IID){ - double Unknown = std::numeric_limits<double>::infinity(); - double Throughput = Unknown; + Optional<double> Throughput; for (const InstrStage *IS = IID->beginStage(schedClass), *E = IID->endStage(schedClass); IS != E; ++IS) { - unsigned Cycles = IS->getCycles(); - if (!Cycles) - continue; - Throughput = - std::min(Throughput, countPopulation(IS->getUnits()) * 1.0 / Cycles); + if (IS->getCycles()) { + double Temp = countPopulation(IS->getUnits()) * 1.0 / IS->getCycles(); + Throughput = Throughput.hasValue() + ? std::min(Throughput.getValue(), Temp) + : Temp; + } } - // We need reciprocal throughput that's why we return such value. - return 1 / Throughput; + if (Throughput.hasValue()) + // We need reciprocal throughput that's why we return such value. + return 1 / Throughput.getValue(); + return Throughput; } static Optional<double> getRThroughputFromInstrSchedModel(const MCSchedClassDesc *SCDesc, const TargetSubtargetInfo *STI, const MCSchedModel &SchedModel) { - double Unknown = std::numeric_limits<double>::infinity(); - double Throughput = Unknown; + Optional<double> Throughput; for (const MCWriteProcResEntry *WPR = STI->getWriteProcResBegin(SCDesc), *WEnd = STI->getWriteProcResEnd(SCDesc); WPR != WEnd; ++WPR) { - unsigned Cycles = WPR->Cycles; - if (!Cycles) - return Optional<double>(); - - unsigned NumUnits = - SchedModel.getProcResource(WPR->ProcResourceIdx)->NumUnits; - Throughput = std::min(Throughput, NumUnits * 1.0 / Cycles); + if (WPR->Cycles) { + unsigned NumUnits = + SchedModel.getProcResource(WPR->ProcResourceIdx)->NumUnits; + double Temp = NumUnits * 1.0 / WPR->Cycles; + Throughput = Throughput.hasValue() + ? std::min(Throughput.getValue(), Temp) + : Temp; + } } - // We need reciprocal throughput that's why we return such value. - return 1 / Throughput; + if (Throughput.hasValue()) + // We need reciprocal throughput that's why we return such value. + return 1 / Throughput.getValue(); + return Throughput; } Optional<double> |