[llvm] TargetInstrInfo: make getOperandLatency return optional (NFC) (PR #73769)
Björn Pettersson via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 4 05:42:35 PST 2023
================
@@ -1452,8 +1452,9 @@ bool TargetInstrInfo::hasLowDefLatency(const TargetSchedModel &SchedModel,
return false;
unsigned DefClass = DefMI.getDesc().getSchedClass();
- int DefCycle = ItinData->getOperandCycle(DefClass, DefIdx);
- return (DefCycle != -1 && DefCycle <= 1);
+ std::optional<unsigned> DefCycle =
+ ItinData->getOperandCycle(DefClass, DefIdx);
+ return DefCycle <= 1;
----------------
bjope wrote:
In the past `DefCycle == -1` resulted in `false`. Now `DefCycle <= 1` is the same as `DefCycle ? *DefCycle : true` so that will return true when getOperandCycle didn't return a proper value.
This at least impacts MachineLICM (when checking `IsCheapInstruction`).
https://github.com/llvm/llvm-project/pull/73769
More information about the llvm-commits
mailing list