[llvm] r333210 - [llvm-mca] Fix a rounding problem in SummaryView.cpp exposed by r333204.

Andrea Di Biagio via llvm-commits llvm-commits at lists.llvm.org
Thu May 24 10:22:14 PDT 2018


Author: adibiagio
Date: Thu May 24 10:22:14 2018
New Revision: 333210

URL: http://llvm.org/viewvc/llvm-project?rev=333210&view=rev
Log:
[llvm-mca] Fix a rounding problem in SummaryView.cpp exposed by r333204.

Before printing the block reciprocal throughput, ensure that the floating point
number is always rounded the same way on every target.
No functional change intended.

Modified:
    llvm/trunk/tools/llvm-mca/SummaryView.cpp

Modified: llvm/trunk/tools/llvm-mca/SummaryView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/SummaryView.cpp?rev=333210&r1=333209&r2=333210&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/SummaryView.cpp (original)
+++ llvm/trunk/tools/llvm-mca/SummaryView.cpp Thu May 24 10:22:14 2018
@@ -34,9 +34,9 @@ void SummaryView::onInstructionEvent(con
     return;
 
   // Update the cumulative number of resource cycles based on the processor
-  // resource usage information available from the instruction descriptor. We need to
-  // compute the cumulative number of resource cycles for every processor
-  // resource which is consumed by an instruction of the block.
+  // resource usage information available from the instruction descriptor. We
+  // need to compute the cumulative number of resource cycles for every
+  // processor resource which is consumed by an instruction of the block.
   const Instruction &Inst = *Event.IR.getInstruction();
   const InstrDesc &Desc = Inst.getDesc();
   NumMicroOps += Desc.NumMicroOps;
@@ -99,7 +99,10 @@ void SummaryView::printView(raw_ostream
   TempStream << "\nTotal Cycles:      " << TotalCycles;
   TempStream << "\nDispatch Width:    " << DispatchWidth;
   TempStream << "\nIPC:               " << format("%.2f", IPC);
-  TempStream << "\nBlock RThroughput: " << format("%.1f", BlockRThroughput)
+
+  // Round to the block reciprocal throughput to the nearest tenth.
+  TempStream << "\nBlock RThroughput: "
+             << format("%.1f", floor((BlockRThroughput * 10) + 0.5) / 10)
              << '\n';
   TempStream.flush();
   OS << Buffer;




More information about the llvm-commits mailing list