[llvm] [AArch64] Implement latency costs for loads (PR #201567)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 18 09:30:30 PDT 2026


================
@@ -5115,7 +5117,9 @@ InstructionCost AArch64TTIImpl::getMemoryOpCost(unsigned Opcode, Type *Ty,
     const MCSchedModel &Sched = ST->getSchedModel();
     const TargetInstrInfo *TII = ST->getInstrInfo();
     unsigned SchedClass = TII->get(Inst).getSchedClass();
-    return (LT.first - 1) + Sched.computeInstrLatency(*ST, SchedClass);
+    const MCSchedClassDesc *SCD = Sched.getSchedClassDesc(SchedClass);
+    return (LT.first - 1) * Sched.getReciprocalThroughput(*ST, *SCD) +
+           Sched.computeInstrLatency(*ST, *SCD);
----------------
sdesmalen-arm wrote:

This is still missing some multiplication with the latency, e.g.:

```
ops=4, latency=8, throughput=4
x x x x x x x x                       8
  x x x x x x x x                     8+1
    x x x x x x x x                   8+2
      x x x x x x x x                 8+3
ops=4, latency=8, throughput=2
x x x x x x x x                       8
  x x x x x x x x                     8+1
                x x x x x x x x       8*2
                  x x x x x x x x     8*2+1
```
so `(ops/throughput) * latency + (ops/throughput - 1)`?

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


More information about the llvm-commits mailing list