crypto/sha1: shorten MIX dependency chain on loong64

MIX(a, b, c, d, e, key) previously computed
e = e + f + w[i] + k + ROTL(a,5) as four ADD instructions chained
serially through e, even though f, w[i], k, and ROTL(a,5) are
mutually independent and only need to be combined into e at the end.

On the 3C6000, the performance of sha1‑related operations is
improved by 2.81%.

goos: linux
goarch: loong64
pkg: crypto/sha1
cpu: Loongson-3C6000/S @ 2200.00MHz
                 |  bench.old  |             bench.new              |
                 |   sec/op    |   sec/op     vs base               |
Hash8Bytes/New     203.3n ± 0%   199.6n ± 0%  -1.82% (p=0.000 n=10)
Hash8Bytes/Sum     202.1n ± 0%   195.4n ± 0%  -3.34% (p=0.000 n=10)
Hash320Bytes/New   965.8n ± 0%   934.7n ± 0%  -3.23% (p=0.000 n=10)
Hash320Bytes/Sum   963.1n ± 0%   934.6n ± 0%  -2.96% (p=0.000 n=10)
Hash1K/New         2.642µ ± 0%   2.566µ ± 0%  -2.88% (p=0.000 n=10)
Hash1K/Sum         2.640µ ± 0%   2.564µ ± 0%  -2.88% (p=0.000 n=10)
Hash8K/New         19.64µ ± 0%   19.14µ ± 0%  -2.54% (p=0.000 n=10)
Hash8K/Sum         19.70µ ± 0%   19.15µ ± 0%  -2.82% (p=0.000 n=10)
geomean            1.785µ        1.735µ       -2.81%

                 |  bench.old   |              bench.new              |
                 |     B/s      |     B/s       vs base               |
Hash8Bytes/New     37.54Mi ± 0%   38.21Mi ± 0%  +1.80% (p=0.000 n=10)
Hash8Bytes/Sum     37.74Mi ± 0%   39.05Mi ± 0%  +3.49% (p=0.000 n=10)
Hash320Bytes/New   316.0Mi ± 0%   326.5Mi ± 0%  +3.33% (p=0.000 n=10)
Hash320Bytes/Sum   316.9Mi ± 0%   326.5Mi ± 0%  +3.05% (p=0.000 n=10)
Hash1K/New         369.7Mi ± 0%   380.6Mi ± 0%  +2.95% (p=0.000 n=10)
Hash1K/Sum         369.9Mi ± 0%   380.9Mi ± 0%  +2.98% (p=0.000 n=10)
Hash8K/New         397.9Mi ± 0%   408.2Mi ± 0%  +2.60% (p=0.000 n=10)
Hash8K/Sum         396.5Mi ± 0%   408.0Mi ± 0%  +2.91% (p=0.000 n=10)
geomean            204.5Mi        210.4Mi       +2.89%

This CL also adds comments to the macro definitions and a short
overview above them documenting these implicit inputs/outputs, so
that future changes to these macros don't inadvertently break the
cross-macro data flow.

Change-Id: I0cc8bb35d3cfd9c59f8bd73d891e731e7de23ca8
Reviewed-on: https://go-review.googlesource.com/c/go/+/818380
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Cherry Mui <cherryyz@google.com>
1 file changed
tree: 0c70660eb1763aab4e96cb78837b8b1ec98c97e5
  1. .github/
  2. api/
  3. doc/
  4. lib/
  5. misc/
  6. src/
  7. test/
  8. .gitattributes
  9. .gitignore
  10. codereview.cfg
  11. CONTRIBUTING.md
  12. go.env
  13. LICENSE
  14. PATENTS
  15. README.md
  16. SECURITY.md
README.md

The Go Programming Language

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

Gopher image Gopher image by Renee French, licensed under Creative Commons 4.0 Attribution license.

Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.

Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.

Download and Install

Binary Distributions

Official binary distributions are available at https://go.dev/dl/.

After downloading a binary release, visit https://go.dev/doc/install for installation instructions.

Install From Source

If a binary distribution is not available for your combination of operating system and architecture, visit https://go.dev/doc/install/source for source installation instructions.

Contributing

Go is the work of thousands of contributors. We appreciate your help!

To contribute, please read the contribution guidelines at https://go.dev/doc/contribute.

Note that the Go project uses the issue tracker for bug reports and proposals only. See https://go.dev/wiki/Questions for a list of places to ask questions about the Go language.