[llvm] [llvm-mca] Add command line option `-use-load-latency` (PR #94566)

Andrea Di Biagio via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 10 06:15:14 PDT 2024


================
@@ -230,6 +231,13 @@ static void computeMaxLatency(InstrDesc &ID, const MCInstrDesc &MCDesc,
   }
 
   int Latency = MCSchedModel::computeInstrLatency(STI, SCDesc);
+
+  // If `UseLoadLatency` is set, we use the value in `MCSchedModel::LoadLatency`
+  // for load instructions.
+  if (MCDesc.mayLoad() && UseLoadLatency) {
+    const MCSchedModel &SM = STI.getSchedModel();
+    Latency = std::max(int(SM.LoadLatency), Latency);
+  }
----------------
adibiagio wrote:

Sorry but this doesn't work.

You cannot simply override Latency that way. Latency of Instructions with folded memory operands isn't just equivalent to the load latency.

To further complicate matters, it is wrong to assume a single load latency value for all memory operations.
For example, on AMD processors, the `load-to-use` latency changes depending on whether the opcode is INT or FPU.
That is because there is an extra delay in the data path when loaded values are forwarded to the floating point unit (often implemented as a coprocessor).

https://github.com/llvm/llvm-project/pull/94566


More information about the llvm-commits mailing list