Skip to content

Commit

Permalink
cmd/compile: cast riscv64 rewrite shifts to unsigned int
Browse files Browse the repository at this point in the history
This appeases Go 1.4, making it possible to bootstrap GOARCH=riscv64 with
a Go 1.4 compiler.

Fixes #52583

Change-Id: Ib13c2afeb095b2bb1464dcd7f1502574209bc7ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/409974
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
  • Loading branch information
4a6f656c committed Jun 6, 2022
1 parent d43ddc1 commit 95547ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/cmd/compile/internal/ssa/gen/RISCV64.rules
Expand Up @@ -735,9 +735,9 @@
(NEGW (MOVDconst [x])) => (MOVDconst [int64(int32(-x))])

// Shift of a constant.
(SLLI [x] (MOVDconst [y])) && is32Bit(y << x) => (MOVDconst [y << x])
(SRLI [x] (MOVDconst [y])) => (MOVDconst [int64(uint64(y) >> x)])
(SRAI [x] (MOVDconst [y])) => (MOVDconst [int64(y) >> x])
(SLLI [x] (MOVDconst [y])) && is32Bit(y << uint32(x)) => (MOVDconst [y << uint32(x)])
(SRLI [x] (MOVDconst [y])) => (MOVDconst [int64(uint64(y) >> uint32(x))])
(SRAI [x] (MOVDconst [y])) => (MOVDconst [int64(y) >> uint32(x)])

// SLTI/SLTIU with constants.
(SLTI [x] (MOVDconst [y])) => (MOVDconst [b2i(int64(y) < int64(x))])
Expand Down
16 changes: 8 additions & 8 deletions src/cmd/compile/internal/ssa/rewriteRISCV64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 95547ae

Please sign in to comment.