Skip to content

Commit 6718dbf

Browse files
committed
[region-isolation] Change how we compute max in separateRegions as we loop rather than using a functional 2nd loop before the main loop.
1 parent a46025d commit 6718dbf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

include/swift/SILOptimizer/Utils/PartitionUtils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,12 @@ class Partition {
361361
if (indices.empty())
362362
return p;
363363

364-
Region max_index =
365-
Region(*std::max_element(indices.begin(), indices.end()));
366-
p.fresh_label = Region(max_index + 1);
364+
auto maxIndex = Element(0);
367365
for (Element index : indices) {
368366
p.labels.insert_or_assign(index, Region(index));
367+
maxIndex = Element(std::max(maxIndex, index));
369368
}
369+
p.fresh_label = Region(maxIndex + 1);
370370
assert(p.is_canonical_correct());
371371
return p;
372372
}

0 commit comments

Comments
 (0)