[llvm] [CodeGen][MISched] Handle empty sized resource usage. (PR #75951)
Francesco Petrogalli via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 18 01:14:13 PST 2024
================
@@ -4266,6 +4266,12 @@ unsigned ResourceSegments::getFirstAvailableAt(
assert(std::is_sorted(std::begin(_Intervals), std::end(_Intervals),
sortIntervals) &&
"Cannot execute on an un-sorted set of intervals.");
+
+ // Zero resource usage is allowed by TargetSchedule.td but we do not construct
+ // a ResourceSegment interval for that situation.
----------------
fpetrogalli wrote:
> It should return CurrCycle since it is as if the for loop below hit the continue statement every time since nothing intersects with the empty interval.
I see, so this is an optimisation of the algorithm, not a functional change. It would be best not to add such optimisations (more code, more bugs!), unless there is a significant slow down in compile time.
If you want this optimisation, I would rephrase the comment as
```suggestion
// Empty resource intervals (`AcquireAtCycle == ReleaseAtCycle`)
// are not stored in a ResourcesSegment.
// However, zero resource usage is allowed by TargetSchedule.td.
// If we deal with an empty interval, we can just return CurrCycle since
// it is as if the for loop below hit the continue statement every time,
// since nothing intersects with the empty interval.
```
https://github.com/llvm/llvm-project/pull/75951
More information about the llvm-commits
mailing list