Skip to content

Commit c77ada1

Browse files
mrclmrrandall77
authored andcommitted
cmd/compile/internal/ssa: simplify with built-in min, max functions
Change-Id: I08fa2940cd3565c578b1b323656a4fa12e0c65bb GitHub-Last-Rev: 1f673b1 GitHub-Pull-Request: #73322 Reviewed-on: https://go-review.googlesource.com/c/go/+/664675 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Keith Randall <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent bbf4d57 commit c77ada1

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/cmd/compile/internal/ssa/writebarrier.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -637,17 +637,12 @@ func (f *Func) computeZeroMap(select1 []*Value) map[ID]ZeroRegion {
637637
size += ptrSize - d
638638
}
639639
// Clip to the 64 words that we track.
640-
min := off
641-
max := off + size
642-
if min < 0 {
643-
min = 0
644-
}
645-
if max > 64*ptrSize {
646-
max = 64 * ptrSize
647-
}
640+
minimum := max(off, 0)
641+
maximum := min(off+size, 64*ptrSize)
642+
648643
// Clear bits for parts that we are writing (and hence
649644
// will no longer necessarily be zero).
650-
for i := min; i < max; i += ptrSize {
645+
for i := minimum; i < maximum; i += ptrSize {
651646
bit := i / ptrSize
652647
z.mask &^= 1 << uint(bit)
653648
}

0 commit comments

Comments
 (0)