[llvm] TargetInstrInfo: make getOperandLatency return optional (NFC) (PR #73769)
Francesco Petrogalli via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 1 00:31:25 PST 2023
================
@@ -173,11 +173,14 @@ 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;
if (hasInstrItineraries()) {
- int OperLatency = 0;
+ std::optional<unsigned> OperLatency = 0;
----------------
fpetrogalli wrote:
I think you want this:
```suggestion
std::optional<unsigned> OperLatency;
```
Otherwise the optional `has_value() == true`.
I am aware it is not a problem for the current code, but if someone modifies the if/else following the declaration we might end up thinking that the OpenradLatency is set, when it is not.
https://github.com/llvm/llvm-project/pull/73769
More information about the llvm-commits
mailing list