mirror of
https://github.com/golang/go.git
synced 2026-06-28 20:00:31 +00:00
cmd/compile: add Sext support to known bits
This doesn't have any hits in the std. Updates #78633 Change-Id: I965838f876e90189f546355093997d64ec13cb35 Reviewed-on: https://go-review.googlesource.com/c/go/+/765802 Auto-Submit: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: Mark Freeman <markfreeman@google.com> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
d75902b195
commit
8963c303b4
2 changed files with 18 additions and 2 deletions
|
|
@ -44,7 +44,7 @@ func (kb *knownBitsState) fold(v *Value) (value, known int64) {
|
|||
kb.seenValues.Set(uint32(v.ID)) // set seen early to give up on loops
|
||||
|
||||
switch v.Op {
|
||||
// TODO: Shifts, rotates, extensions, ...
|
||||
// TODO: Shifts, rotates, ...
|
||||
case OpConst64, OpConst32, OpConst16, OpConst8, OpConstBool:
|
||||
return v.AuxInt, -1
|
||||
case OpAnd64, OpAnd32, OpAnd16, OpAnd8, OpAndB:
|
||||
|
|
@ -87,7 +87,8 @@ func (kb *knownBitsState) fold(v *Value) (value, known int64) {
|
|||
}
|
||||
}
|
||||
return value, known
|
||||
case OpCopy, OpCvtBoolToUint8:
|
||||
case OpCopy, OpCvtBoolToUint8,
|
||||
OpSignExt8to16, OpSignExt8to32, OpSignExt8to64, OpSignExt16to32, OpSignExt16to64, OpSignExt32to64:
|
||||
return kb.fold(v.Args[0])
|
||||
case OpEq64, OpEq32, OpEq16, OpEq8, OpEqB:
|
||||
x, xk := kb.fold(v.Args[0])
|
||||
|
|
|
|||
|
|
@ -214,3 +214,18 @@ func knownBitsCvtBoolToUint8True(x int64, cond bool) uint8 {
|
|||
func unknownBitsCvtBoolToUint8(cond bool) uint8 {
|
||||
return cvtBoolToUint8(cond) & 1
|
||||
}
|
||||
|
||||
func knownBitsSignExtPassThrough(x int8) int64 {
|
||||
x |= 6
|
||||
return int64(x) & 6 // ERROR "known value of v[0-9]+ \(And64\): 6$"
|
||||
}
|
||||
|
||||
func knownBitsSignExtUpperHalf(x int16) int32 {
|
||||
x |= -1 << 15
|
||||
return int32(x) & (-1 << 16) // ERROR "known value of v[0-9]+ \(And32\): -65536$"
|
||||
}
|
||||
|
||||
func unknownBitsSignExt(x int16) int32 {
|
||||
x |= -0b010101010101010
|
||||
return int32(x) & -1 << 12
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue