Skip to content

Commit b44b360

Browse files
committed
math/big: add more complete tests and benchmarks of assembly
Also fix a few real but currently harmless bugs from CL 664895. There were a few places that were still wrong if z != x or if a != 0. Change-Id: Id8971e2505523bc4708780c82bf998a546f4f081 Reviewed-on: https://go-review.googlesource.com/c/go/+/664897 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
1 parent 930cf59 commit b44b360

File tree

4 files changed

+609
-367
lines changed

4 files changed

+609
-367
lines changed

src/math/big/arith_amd64.s

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ adx:
430430
MOVQ y+48(FP), R8
431431
MOVQ m+72(FP), DX
432432
MOVQ $0, BX // i = 0
433-
MOVQ $0, CX // carry
433+
MOVQ a+80(FP), CX // carry
434434
CMPQ R11, $8
435435
JAE adx_loop_header
436436
CMPQ BX, R11
@@ -446,7 +446,7 @@ adx_loop:
446446
MULXQ (R8), SI, DI
447447
ADCXQ CX,SI
448448
ADOXQ (R10), SI
449-
MOVQ SI,(R10)
449+
MOVQ SI,(R14)
450450

451451
MULXQ 8(R8), AX, CX
452452
ADCXQ DI, AX
@@ -505,7 +505,8 @@ adx_short:
505505
MULXQ (R8)(BX*8), SI, DI
506506
ADDQ CX, SI
507507
ADCQ $0, DI
508-
ADDQ SI, (R10)(BX*8)
508+
ADDQ (R10)(BX*8), SI
509+
MOVQ SI, (R14)(BX*8)
509510
ADCQ $0, DI
510511
MOVQ DI, CX
511512
ADDQ $1, BX // i++

src/math/big/arith_s390x_test.go

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,10 @@
66

77
package big
88

9-
import (
10-
"testing"
11-
)
9+
import "testing"
1210

13-
// Tests whether the non vector routines are working, even when the tests are run on a
14-
// vector-capable machine
15-
16-
func TestFunVVnovec(t *testing.T) {
17-
if hasVX {
18-
for _, a := range sumVV {
19-
arg := a
20-
testFunVV(t, "addVV_novec", addVV_novec, arg)
21-
22-
arg = argVV{a.z, a.y, a.x, a.c}
23-
testFunVV(t, "addVV_novec symmetric", addVV_novec, arg)
24-
25-
arg = argVV{a.x, a.z, a.y, a.c}
26-
testFunVV(t, "subVV_novec", subVV_novec, arg)
27-
28-
arg = argVV{a.y, a.z, a.x, a.c}
29-
testFunVV(t, "subVV_novec symmetric", subVV_novec, arg)
30-
}
31-
}
11+
func TestNoVec(t *testing.T) {
12+
// Make sure non-vector versions match vector versions.
13+
t.Run("AddVV", func(t *testing.T) { testVV(t, "addVV_novec", addVV_novec, addVV) })
14+
t.Run("SubVV", func(t *testing.T) { testVV(t, "subVV_novec", subVV_novec, subVV) })
3215
}

0 commit comments

Comments
 (0)