]> Cypherpunks repositories - gostls13.git/commit
cmd/compile/internal/ssa: optimise more branches with zero on riscv64
authorJoel Sing <joel@sing.id.au>
Mon, 19 Aug 2024 13:57:56 +0000 (23:57 +1000)
committerJoel Sing <joel@sing.id.au>
Fri, 28 Mar 2025 08:27:22 +0000 (01:27 -0700)
commite6c2e12c63db5b24724db873009373af413cd1ea
tree554f9d18c1804a2e5b6b0ad371d2f8ded3a44233
parentcfc784a152ebbc4fc0b8bf13c02e0f6eb9c980bd
cmd/compile/internal/ssa: optimise more branches with zero on riscv64

Optimise more branches with zero on riscv64. In particular, BLTU with
zero occurs with IsInBounds checks for index zero. This currently results
in two instructions and requires an additional register:

   li      t2, 0
   bltu    t2, t1, 0x174b4

This is equivalent to checking if the bounds is not equal to zero. With
this change:

   bnez    t1, 0x174c0

This removes more than 500 instructions from the Go binary on riscv64.

Change-Id: I6cd861d853e3ef270bd46dacecdfaa205b1c4644
Reviewed-on: https://go-review.googlesource.com/c/go/+/606715
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
src/cmd/compile/internal/ssa/_gen/RISCV64.rules
src/cmd/compile/internal/ssa/rewriteRISCV64.go
test/codegen/compare_and_branch.go