mirror of
https://github.com/golang/go.git
synced 2025-11-01 01:00:56 +00:00
cmd/compile: optimize bounded shifts on wasm
Use the shiftIsBounded function to generate more efficient Shift instructions. Updates #25167 Change-Id: Id350f8462dc3a7ed3bfed0bcbea2860b8f40048a Reviewed-on: https://go-review.googlesource.com/c/go/+/182558 Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Richard Musiol <neelance@gmail.com>
This commit is contained in:
parent
b9ef4c0f56
commit
8fedb2d338
3 changed files with 50 additions and 5 deletions
|
|
@ -102,9 +102,9 @@ func lshSignedMasked(v8 int8, v16 int16, v32 int32, v64 int64, x int) {
|
|||
// bounded shifts //
|
||||
// ------------------ //
|
||||
|
||||
func lshGuarded64(v int64, s uint) int64 {
|
||||
func rshGuarded64(v int64, s uint) int64 {
|
||||
if s < 64 {
|
||||
// s390x:-".*AND",-".*MOVDGE"
|
||||
// s390x:-".*AND",-".*MOVDGE" wasm:-"Select",-".*LtU"
|
||||
return v >> s
|
||||
}
|
||||
panic("shift too large")
|
||||
|
|
@ -112,15 +112,15 @@ func lshGuarded64(v int64, s uint) int64 {
|
|||
|
||||
func rshGuarded64U(v uint64, s uint) uint64 {
|
||||
if s < 64 {
|
||||
// s390x:-".*AND",-".*MOVDGE"
|
||||
// s390x:-".*AND",-".*MOVDGE" wasm:-"Select",-".*LtU"
|
||||
return v >> s
|
||||
}
|
||||
panic("shift too large")
|
||||
}
|
||||
|
||||
func rshGuarded64(v int64, s uint) int64 {
|
||||
func lshGuarded64(v int64, s uint) int64 {
|
||||
if s < 64 {
|
||||
// s390x:-".*AND",-".*MOVDGE"
|
||||
// s390x:-".*AND",-".*MOVDGE" wasm:-"Select",-".*LtU"
|
||||
return v << s
|
||||
}
|
||||
panic("shift too large")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue