Skip to content

Commit e8dbe94

Browse files
authored
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.
1 parent 0ca80eb commit e8dbe94

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

llvm/lib/CodeGen/TargetInstrInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ bool TargetInstrInfo::hasLowDefLatency(const TargetSchedModel &SchedModel,
14621462
unsigned DefClass = DefMI.getDesc().getSchedClass();
14631463
std::optional<unsigned> DefCycle =
14641464
ItinData->getOperandCycle(DefClass, DefIdx);
1465-
return DefCycle <= 1U;
1465+
return DefCycle && DefCycle <= 1U;
14661466
}
14671467

14681468
bool TargetInstrInfo::isFunctionSafeToSplit(const MachineFunction &MF) const {

llvm/lib/CodeGen/TargetSchedule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ unsigned TargetSchedModel::computeOperandLatency(
178178
const unsigned DefaultDefLatency = TII->defaultDefLatency(SchedModel, *DefMI);
179179

180180
if (!hasInstrSchedModel() && !hasInstrItineraries())
181-
return InstrLatency;
181+
return DefaultDefLatency;
182182

183183
if (hasInstrItineraries()) {
184184
std::optional<unsigned> OperLatency;

llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4836,7 +4836,7 @@ bool ARMBaseInstrInfo::hasLowDefLatency(const TargetSchedModel &SchedModel,
48364836
unsigned DefClass = DefMI.getDesc().getSchedClass();
48374837
std::optional<unsigned> DefCycle =
48384838
ItinData->getOperandCycle(DefClass, DefIdx);
4839-
return DefCycle <= 2U;
4839+
return DefCycle && DefCycle <= 2U;
48404840
}
48414841
return false;
48424842
}

0 commit comments

Comments
 (0)