mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: rewrite Rsh to RshU if arguments are proved positive
Fixes #76332 Change-Id: I9044025d5dc599531c7f88ed2870bcf3d8b0acbd Reviewed-on: https://go-review.googlesource.com/c/go/+/721206 Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Jorropo <jorropo.pgm@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
3820f94c1d
commit
ec92bc6d63
3 changed files with 43 additions and 20 deletions
|
|
@ -30,10 +30,10 @@ func f0u(x uint) int {
|
|||
}
|
||||
|
||||
if x < 1000 {
|
||||
return int(x)>>31 // ERROR "Proved.+is constant 0$"
|
||||
return int(x) >> 31 // ERROR "(Proved.+is constant 0|Proved Rsh[0-9]+x[0-9]+ is unsigned)$"
|
||||
}
|
||||
if x := int32(x); x < -1000 {
|
||||
return int(x>>31) // ERROR "Proved.+is constant -1$"
|
||||
return int(x >> 31) // ERROR "Proved.+is constant -1$"
|
||||
}
|
||||
|
||||
return int(x) + 1
|
||||
|
|
@ -45,35 +45,35 @@ func sh64(n int64) int64 {
|
|||
if n < 0 {
|
||||
return n
|
||||
}
|
||||
return n >> 63 // ERROR "Proved .+ is constant 0$"
|
||||
return n >> 63 // ERROR "(Proved .+ is constant 0|Proved Rsh[0-9]+x[0-9]+ is unsigned)$"
|
||||
}
|
||||
|
||||
func sh32(n int32) int32 {
|
||||
if n < 0 {
|
||||
return n
|
||||
}
|
||||
return n >> 31 // ERROR "Proved .+ is constant 0$"
|
||||
return n >> 31 // ERROR "(Proved .+ is constant 0|Proved Rsh[0-9]+x[0-9]+ is unsigned)$"
|
||||
}
|
||||
|
||||
func sh32x64(n int32) int32 {
|
||||
if n < 0 {
|
||||
return n
|
||||
}
|
||||
return n >> uint64(31) // ERROR "Proved .+ is constant 0$"
|
||||
return n >> uint64(31) // ERROR "(Proved .+ is constant 0|Proved Rsh[0-9]+x[0-9]+ is unsigned)$"
|
||||
}
|
||||
|
||||
func sh32x64n(n int32) int32 {
|
||||
if n >= 0 {
|
||||
return 0
|
||||
}
|
||||
return n >> 31// ERROR "Proved .+ is constant -1$"
|
||||
return n >> 31 // ERROR "Proved .+ is constant -1$"
|
||||
}
|
||||
|
||||
func sh16(n int16) int16 {
|
||||
if n < 0 {
|
||||
return n
|
||||
}
|
||||
return n >> 15 // ERROR "Proved .+ is constant 0$"
|
||||
return n >> 15 // ERROR "(Proved .+ is constant 0|Proved Rsh[0-9]+x[0-9]+ is unsigned)$"
|
||||
}
|
||||
|
||||
func sh64noopt(n int64) int64 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue