[llvm] TargetInstrInfo: make getOperandLatency return optional (NFC) (PR #73769)

Björn Pettersson via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 4 04:26:06 PST 2023


================
@@ -168,16 +168,20 @@ static unsigned findUseIdx(const MachineInstr *MI, unsigned UseOperIdx) {
   return UseIdx;
 }
 
-// Top-level API for clients that know the operand indices.
+// Top-level API for clients that know the operand indices. This doesn't need to
+// return std::optional<unsigned>, as it always returns a valid latency.
 unsigned TargetSchedModel::computeOperandLatency(
   const MachineInstr *DefMI, unsigned DefOperIdx,
   const MachineInstr *UseMI, unsigned UseOperIdx) const {
 
+  const unsigned InstrLatency = computeInstrLatency(DefMI);
+  const unsigned DefaultDefLatency = TII->defaultDefLatency(SchedModel, *DefMI);
+
   if (!hasInstrSchedModel() && !hasInstrItineraries())
-    return TII->defaultDefLatency(SchedModel, *DefMI);
+    return InstrLatency;
----------------
bjope wrote:

But `computeInstrLatency` is for example always making an early out for `MI->isBundle()`. Are you sure that `InstrLatency==DefaultDefLatency` here?

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


More information about the llvm-commits mailing list