[llvm] e8dbe94 - TargetInstrInfo, TargetSchedule: fix non-NFC parts of 9468de4 (#74338)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 5 00:18:21 PST 2023
Author: Ramkumar Ramachandra
Date: 2023-12-05T08:18:17Z
New Revision: e8dbe945f39f2249fe24e0d62ec8ac998e853c2b
URL: https://github.com/llvm/llvm-project/commit/e8dbe945f39f2249fe24e0d62ec8ac998e853c2b
DIFF: https://github.com/llvm/llvm-project/commit/e8dbe945f39f2249fe24e0d62ec8ac998e853c2b.diff
LOG: TargetInstrInfo, TargetSchedule: fix non-NFC parts of 9468de4 (#74338)
Follow up on a post-commit review of 9468de4 (TargetInstrInfo: make
getOperandLatency return optional (NFC)) by Bjorn Pettersson to fix a
couple of things that are not NFC:
- std::optional<T>::operator<= returns true if the first operand is a
std::nullopt and second operand is T. Fix a couple of places where we
assumed it would return false.
- In TargetSchedule, computeInstrCost could take another codepath,
returning InstrLatency instead of DefaultDefLatency. Fix one instance
not accounting for this behavior.
Added:
Modified:
llvm/lib/CodeGen/TargetInstrInfo.cpp
llvm/lib/CodeGen/TargetSchedule.cpp
llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/TargetInstrInfo.cpp b/llvm/lib/CodeGen/TargetInstrInfo.cpp
index 4bd5c910b298d..4783742a14ad7 100644
--- a/llvm/lib/CodeGen/TargetInstrInfo.cpp
+++ b/llvm/lib/CodeGen/TargetInstrInfo.cpp
@@ -1462,7 +1462,7 @@ bool TargetInstrInfo::hasLowDefLatency(const TargetSchedModel &SchedModel,
unsigned DefClass = DefMI.getDesc().getSchedClass();
std::optional<unsigned> DefCycle =
ItinData->getOperandCycle(DefClass, DefIdx);
- return DefCycle <= 1U;
+ return DefCycle && DefCycle <= 1U;
}
bool TargetInstrInfo::isFunctionSafeToSplit(const MachineFunction &MF) const {
diff --git a/llvm/lib/CodeGen/TargetSchedule.cpp b/llvm/lib/CodeGen/TargetSchedule.cpp
index a25d4ff78f4d9..ce59b096992d8 100644
--- a/llvm/lib/CodeGen/TargetSchedule.cpp
+++ b/llvm/lib/CodeGen/TargetSchedule.cpp
@@ -178,7 +178,7 @@ unsigned TargetSchedModel::computeOperandLatency(
const unsigned DefaultDefLatency = TII->defaultDefLatency(SchedModel, *DefMI);
if (!hasInstrSchedModel() && !hasInstrItineraries())
- return InstrLatency;
+ return DefaultDefLatency;
if (hasInstrItineraries()) {
std::optional<unsigned> OperLatency;
diff --git a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
index 476a9bb15edbf..b85107ec47191 100644
--- a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
@@ -4836,7 +4836,7 @@ bool ARMBaseInstrInfo::hasLowDefLatency(const TargetSchedModel &SchedModel,
unsigned DefClass = DefMI.getDesc().getSchedClass();
std::optional<unsigned> DefCycle =
ItinData->getOperandCycle(DefClass, DefIdx);
- return DefCycle <= 2U;
+ return DefCycle && DefCycle <= 2U;
}
return false;
}
More information about the llvm-commits
mailing list