[llvm] TargetSchedule: factor out code in computeOperandLatency (NFC) (PR #73769)

Francesco Petrogalli via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 30 02:01:41 PST 2023


================
@@ -186,21 +189,16 @@ unsigned TargetSchedModel::computeOperandLatency(
       unsigned DefClass = DefMI->getDesc().getSchedClass();
       OperLatency = InstrItins.getOperandCycle(DefClass, DefOperIdx);
     }
-    if (OperLatency >= 0)
-      return OperLatency;
-
-    // No operand latency was found.
-    unsigned InstrLatency = TII->getInstrLatency(&InstrItins, *DefMI);
 
     // Expected latency is the max of the stage latency and itinerary props.
     // Rather than directly querying InstrItins stage latency, we call a TII
     // hook to allow subtargets to specialize latency. This hook is only
     // applicable to the InstrItins model. InstrSchedModel should model all
     // special cases without TII hooks.
-    InstrLatency =
-        std::max(InstrLatency, TII->defaultDefLatency(SchedModel, *DefMI));
-    return InstrLatency;
+    return OperLatency >= 0 ? OperLatency
----------------
fpetrogalli wrote:

I am a bit confused - you cannot use `.has_value()` here, unless you change the interface of the TII to return std::optional<unsigned>. Unless I am missing something, I do not expect this code to build.

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


More information about the llvm-commits mailing list