Skip to content

Commit 72b588d

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 1d7dba1 + 21acfdc commit 72b588d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+494
-593
lines changed

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

Lines changed: 20 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -133,62 +133,38 @@ func (l limit) String() string {
133133
}
134134

135135
func (l limit) intersect(l2 limit) limit {
136-
if l.min < l2.min {
137-
l.min = l2.min
138-
}
139-
if l.umin < l2.umin {
140-
l.umin = l2.umin
141-
}
142-
if l.max > l2.max {
143-
l.max = l2.max
144-
}
145-
if l.umax > l2.umax {
146-
l.umax = l2.umax
147-
}
136+
l.min = max(l.min, l2.min)
137+
l.umin = max(l.umin, l2.umin)
138+
l.max = min(l.max, l2.max)
139+
l.umax = min(l.umax, l2.umax)
148140
return l
149141
}
150142

151143
func (l limit) signedMin(m int64) limit {
152-
if l.min < m {
153-
l.min = m
154-
}
144+
l.min = max(l.min, m)
155145
return l
156146
}
157147
func (l limit) signedMax(m int64) limit {
158-
if l.max > m {
159-
l.max = m
160-
}
148+
l.max = min(l.max, m)
161149
return l
162150
}
163-
func (l limit) signedMinMax(min, max int64) limit {
164-
if l.min < min {
165-
l.min = min
166-
}
167-
if l.max > max {
168-
l.max = max
169-
}
151+
func (l limit) signedMinMax(minimum, maximum int64) limit {
152+
l.min = max(l.min, minimum)
153+
l.max = min(l.max, maximum)
170154
return l
171155
}
172156

173157
func (l limit) unsignedMin(m uint64) limit {
174-
if l.umin < m {
175-
l.umin = m
176-
}
158+
l.umin = max(l.umin, m)
177159
return l
178160
}
179161
func (l limit) unsignedMax(m uint64) limit {
180-
if l.umax > m {
181-
l.umax = m
182-
}
162+
l.umax = min(l.umax, m)
183163
return l
184164
}
185-
func (l limit) unsignedMinMax(min, max uint64) limit {
186-
if l.umin < min {
187-
l.umin = min
188-
}
189-
if l.umax > max {
190-
l.umax = max
191-
}
165+
func (l limit) unsignedMinMax(minimum, maximum uint64) limit {
166+
l.umin = max(l.umin, minimum)
167+
l.umax = min(l.umax, maximum)
192168
return l
193169
}
194170

@@ -688,7 +664,7 @@ func (ft *factsTable) newLimit(v *Value, newLim limit) bool {
688664
d |= unsigned
689665
}
690666
if !isTrue {
691-
r ^= (lt | gt | eq)
667+
r ^= lt | gt | eq
692668
}
693669
// TODO: v.Block is wrong?
694670
addRestrictions(v.Block, ft, d, v.Args[0], v.Args[1], r)
@@ -721,7 +697,7 @@ func (ft *factsTable) newLimit(v *Value, newLim limit) bool {
721697
// But in the signed domain, we can't express the ||
722698
// condition, so check if a0 is non-negative instead,
723699
// to be able to learn something.
724-
r ^= (lt | gt | eq) // >= (index) or > (slice)
700+
r ^= lt | gt | eq // >= (index) or > (slice)
725701
if ft.isNonNegative(v.Args[0]) {
726702
ft.update(v.Block, v.Args[0], v.Args[1], signed, r)
727703
}
@@ -1323,8 +1299,8 @@ func prove(f *Func) {
13231299
}
13241300

13251301
// try to rewrite to a downward counting loop checking against start if the
1326-
// loop body does not depends on ind or nxt and end is known before the loop.
1327-
// This reduce pressure on the register allocator because this do not need
1302+
// loop body does not depend on ind or nxt and end is known before the loop.
1303+
// This reduces pressure on the register allocator because this does not need
13281304
// to use end on each iteration anymore. We compare against the start constant instead.
13291305
// That means this code:
13301306
//
@@ -1356,7 +1332,7 @@ func prove(f *Func) {
13561332
//
13571333
// exit_loop:
13581334
//
1359-
// this is better because it only require to keep ind then nxt alive while looping,
1335+
// this is better because it only requires to keep ind then nxt alive while looping,
13601336
// while the original form keeps ind then nxt and end alive
13611337
start, end := v.min, v.max
13621338
if v.flags&indVarCountDown != 0 {
@@ -1379,7 +1355,7 @@ func prove(f *Func) {
13791355

13801356
if end.Block == ind.Block {
13811357
// we can't rewrite loops where the condition depends on the loop body
1382-
// this simple check is forced to work because if this is true a Phi in ind.Block must exists
1358+
// this simple check is forced to work because if this is true a Phi in ind.Block must exist
13831359
continue
13841360
}
13851361

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
}

src/cmd/compile/internal/walk/builtin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ func walkMakeSlice(n *ir.MakeExpr, init *ir.Nodes) ir.Node {
568568
// The conv is necessary in case n.Type is named.
569569
return walkExpr(typecheck.Expr(typecheck.Conv(s, n.Type())), init)
570570
}
571-
tryStack = true
571+
tryStack = base.Flag.N == 0
572572
}
573573

574574
// The final result is assigned to this variable.

src/internal/poll/copy_file_range_unix.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ func CopyFileRange(dst, src *FD, remain int64) (written int64, handled bool, err
1616
}
1717

1818
for remain > 0 {
19-
max := remain
20-
if max > maxCopyFileRangeRound {
21-
max = maxCopyFileRangeRound
22-
}
19+
max := min(remain, maxCopyFileRangeRound)
2320
n, e := copyFileRange(dst, src, int(max))
2421
if n > 0 {
2522
remain -= n

src/math/big/arith.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func subVWlarge(z, x []Word, y Word) (c Word) {
143143
return
144144
}
145145

146-
func shlVU_g(z, x []Word, s uint) (c Word) {
146+
func lshVU_g(z, x []Word, s uint) (c Word) {
147147
if s == 0 {
148148
copy(z, x)
149149
return
@@ -162,7 +162,7 @@ func shlVU_g(z, x []Word, s uint) (c Word) {
162162
return
163163
}
164164

165-
func shrVU_g(z, x []Word, s uint) (c Word) {
165+
func rshVU_g(z, x []Word, s uint) (c Word) {
166166
if s == 0 {
167167
copy(z, x)
168168
return
@@ -194,10 +194,11 @@ func mulAddVWW_g(z, x []Word, y, r Word) (c Word) {
194194
return
195195
}
196196

197-
func addMulVVW_g(z, x []Word, y Word) (c Word) {
197+
func addMulVVWW_g(z, x, y []Word, m, a Word) (c Word) {
198+
c = a
198199
// The comment near the top of this file discusses this for loop condition.
199-
for i := 0; i < len(z) && i < len(x); i++ {
200-
z1, z0 := mulAddWWW_g(x[i], y, z[i])
200+
for i := 0; i < len(z) && i < len(x) && i < len(y); i++ {
201+
z1, z0 := mulAddWWW_g(y[i], m, x[i])
201202
lo, cc := bits.Add(uint(z0), uint(c), 0)
202203
c, z[i] = Word(cc), Word(lo)
203204
c += z1

src/math/big/arith_386.s

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ E4: CMPL BX, BP // i < n
105105
RET
106106

107107

108-
// func shlVU(z, x []Word, s uint) (c Word)
109-
TEXT ·shlVU(SB),NOSPLIT,$0
108+
// func lshVU(z, x []Word, s uint) (c Word)
109+
TEXT ·lshVU(SB),NOSPLIT,$0
110110
MOVL z_len+4(FP), BX // i = z
111111
SUBL $1, BX // i--
112112
JL X8b // i < 0 (n <= 0)
@@ -140,8 +140,8 @@ X8b: MOVL $0, c+28(FP)
140140
RET
141141

142142

143-
// func shrVU(z, x []Word, s uint) (c Word)
144-
TEXT ·shrVU(SB),NOSPLIT,$0
143+
// func rshVU(z, x []Word, s uint) (c Word)
144+
TEXT ·rshVU(SB),NOSPLIT,$0
145145
MOVL z_len+4(FP), BP
146146
SUBL $1, BP // n--
147147
JL X9b // n < 0 (n <= 0)
@@ -177,12 +177,12 @@ X9b: MOVL $0, c+28(FP)
177177
RET
178178

179179

180-
// func mulAddVWW(z, x []Word, y, r Word) (c Word)
180+
// func mulAddVWW(z, x []Word, m, a Word) (c Word)
181181
TEXT ·mulAddVWW(SB),NOSPLIT,$0
182182
MOVL z+0(FP), DI
183183
MOVL x+12(FP), SI
184-
MOVL y+24(FP), BP
185-
MOVL r+28(FP), CX // c = r
184+
MOVL m+24(FP), BP
185+
MOVL a+28(FP), CX // c = a
186186
MOVL z_len+4(FP), BX
187187
LEAL (DI)(BX*4), DI
188188
LEAL (SI)(BX*4), SI
@@ -204,31 +204,33 @@ E5: CMPL BX, $0 // i < 0
204204
RET
205205

206206

207-
// func addMulVVW(z, x []Word, y Word) (c Word)
208-
TEXT ·addMulVVW(SB),NOSPLIT,$0
209-
MOVL z+0(FP), DI
210-
MOVL x+12(FP), SI
211-
MOVL y+24(FP), BP
207+
// func addMulVVWW(z, x, y []Word, m, a Word) (c Word)
208+
TEXT ·addMulVVWW(SB),NOSPLIT,$0
209+
MOVL z+0(FP), BP
210+
MOVL x+12(FP), DI
211+
MOVL y+24(FP), SI
212+
MOVL a+40(FP), CX
212213
MOVL z_len+4(FP), BX
213214
LEAL (DI)(BX*4), DI
214215
LEAL (SI)(BX*4), SI
216+
LEAL (BP)(BX*4), BP
215217
NEGL BX // i = -n
216-
MOVL $0, CX // c = 0
217218
JMP E6
218219

219220
L6: MOVL (SI)(BX*4), AX
220-
MULL BP
221+
MULL m+36(FP)
221222
ADDL CX, AX
222223
ADCL $0, DX
223-
ADDL AX, (DI)(BX*4)
224+
ADDL (DI)(BX*4), AX
225+
MOVL AX, (BP)(BX*4)
224226
ADCL $0, DX
225227
MOVL DX, CX
226228
ADDL $1, BX // i++
227229

228230
E6: CMPL BX, $0 // i < 0
229231
JL L6
230232

231-
MOVL CX, c+28(FP)
233+
MOVL CX, c+44(FP)
232234
RET
233235

234236

0 commit comments

Comments
 (0)