cmd/internal/obj/riscv,internal/bytealg: synthesize MIN/MAX/MINU/MAXU instructions

Provide a synthesized version of the MIN/MAX/MINU/MAXU instructions
if they're not natively available. This allows these instructions to
be used in assembly unconditionally.

Use MIN in internal/bytealg.compare.

Cq-Include-Trybots: luci.golang.try:gotip-linux-riscv64
Change-Id: I8a5a3a59f0a9205e136fc3d673b23eaf3ca469f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/653295
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Joel Sing 2025-02-06 23:29:57 +11:00
parent d37624881f
commit d88f93f720
6 changed files with 339 additions and 14 deletions

View file

@ -264,6 +264,20 @@ func TestBranch(t *testing.T) {
}
}
func TestMinMax(t *testing.T) {
if runtime.GOARCH != "riscv64" {
t.Skip("Requires riscv64 to run")
}
testenv.MustHaveGoBuild(t)
cmd := testenv.Command(t, testenv.GoToolPath(t), "test")
cmd.Dir = "testdata/testminmax"
if out, err := testenv.CleanCmdEnv(cmd).CombinedOutput(); err != nil {
t.Errorf("Min max test failed: %v\n%s", err, out)
}
}
func TestPCAlign(t *testing.T) {
dir := t.TempDir()
tmpfile := filepath.Join(dir, "x.s")