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

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 4 07:39:53 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;
----------------
artagnon wrote:

Thanks for catching this! I looked up the documentation of `std::optional::operator<=`, and found the behavior surprising. Will fix shortly.

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


More information about the llvm-commits mailing list