Skip to content

Commit 1f673b1

Browse files
committed
ssa: simplify with built-in min, max functions
1 parent 2c35900 commit 1f673b1

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
@@ -640,17 +640,12 @@ func (f *Func) computeZeroMap(select1 []*Value) map[ID]ZeroRegion {
640640
size += ptrSize - d
641641
}
642642
// Clip to the 64 words that we track.
643-
min := off
644-
max := off + size
645-
if min < 0 {
646-
min = 0
647-
}
648-
if max > 64*ptrSize {
649-
max = 64 * ptrSize
650-
}
643+
minimum := max(off, 0)
644+
maximum := min(off+size, 64*ptrSize)
645+
651646
// Clear bits for parts that we are writing (and hence
652647
// will no longer necessarily be zero).
653-
for i := min; i < max; i += ptrSize {
648+
for i := minimum; i < maximum; i += ptrSize {
654649
bit := i / ptrSize
655650
z.mask &^= 1 << uint(bit)
656651
}

0 commit comments

Comments
 (0)