]> Cypherpunks repositories - gostls13.git/commit
cmd/asm,cmd/compile,cmd/internal/obj/riscv: use compressed instructions on riscv64
authorJoel Sing <joel@sing.id.au>
Thu, 25 Sep 2025 19:05:49 +0000 (05:05 +1000)
committerJoel Sing <joel@sing.id.au>
Tue, 18 Nov 2025 08:58:00 +0000 (00:58 -0800)
commit9859b436430aac382b337964a1b380bc4bfcda70
tree62dcd5c1a80b6fc8946c7ed58ba8186bc5deaf53
parentb9ef0633f6117c74fabcd7247a76b4feb86df086
cmd/asm,cmd/compile,cmd/internal/obj/riscv: use compressed instructions on riscv64

Make use of compressed instructions on riscv64 - add a compress
pass to the end of the assembler, which replaces non-compressed
instructions with compressed alternatives if possible.

Provide a `compressinstructions` compiler and assembler debug
flag, such that the compression pass can be disabled via
`-asmflags=all=-d=compressinstructions=0` and
`-gcflags=all=-d=compressinstructions=0`. Note that this does
not prevent the explicit use of compressed instructions via
assembly.

Note that this does not make use of compressed control transfer
instructions - this will be implemented in later changes.

Reduces the text size of a hello world binary by ~121KB
and reduces the text size of the go binary on riscv64 by ~1.21MB
(between 8-10% in both cases).

Updates #71105

Cq-Include-Trybots: luci.golang.try:gotip-linux-riscv64
Change-Id: I24258353688554042c2a836deed4830cc673e985
Reviewed-on: https://go-review.googlesource.com/c/go/+/523478
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/asm/internal/flags/flags.go
src/cmd/asm/main.go
src/cmd/compile/internal/base/debug.go
src/cmd/compile/internal/base/flag.go
src/cmd/internal/obj/link.go
src/cmd/internal/obj/riscv/asm_test.go
src/cmd/internal/obj/riscv/cpu.go
src/cmd/internal/obj/riscv/obj.go
src/cmd/link/internal/ld/ld_test.go