mirror of
https://github.com/golang/go
synced 2024-11-11 23:40:22 -07:00
cmd/compile: fold more of CMPQ and ANDQ
g used to produce CMPQ/SBBQ/ANDQ, but f didn't even though s&15 is at most s&63. func f(x uint64, s uint) uint64 { return x >> (s & 63) } func g(x uint64, s uint) uint64 { return x >> (s & 15) } Change-Id: Iab4a1a6e10b471dead9f1203e9d894677cf07bb2 Reviewed-on: https://go-review.googlesource.com/21048 Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
df2b2eb63d
commit
d8ee180ab2
@ -942,10 +942,10 @@
|
||||
(CMPBconst (MOVBconst [x]) [y]) && int8(x)>int8(y) && uint8(x)>uint8(y) -> (FlagGT_UGT)
|
||||
|
||||
// Other known comparisons.
|
||||
(CMPQconst (ANDQconst _ [m]) [n]) && m+1==n && isPowerOfTwo(n) -> (FlagLT_ULT)
|
||||
(CMPLconst (ANDLconst _ [m]) [n]) && int32(m)+1==int32(n) && isPowerOfTwo(int64(int32(n))) -> (FlagLT_ULT)
|
||||
(CMPWconst (ANDWconst _ [m]) [n]) && int16(m)+1==int16(n) && isPowerOfTwo(int64(int16(n))) -> (FlagLT_ULT)
|
||||
(CMPBconst (ANDBconst _ [m]) [n]) && int8(m)+1==int8(n) && isPowerOfTwo(int64(int8(n))) -> (FlagLT_ULT)
|
||||
(CMPQconst (ANDQconst _ [m]) [n]) && 0 <= m && m < n -> (FlagLT_ULT)
|
||||
(CMPLconst (ANDLconst _ [m]) [n]) && 0 <= int32(m) && int32(m) < int32(n) -> (FlagLT_ULT)
|
||||
(CMPWconst (ANDWconst _ [m]) [n]) && 0 <= int16(m) && int16(m) < int16(n) -> (FlagLT_ULT)
|
||||
(CMPBconst (ANDBconst _ [m]) [n]) && 0 <= int8(m) && int8(m) < int8(n) -> (FlagLT_ULT)
|
||||
// TODO: DIVxU also.
|
||||
|
||||
// Absorb flag constants into SBB ops.
|
||||
|
@ -2240,7 +2240,7 @@ func rewriteValueAMD64_OpAMD64CMPBconst(v *Value, config *Config) bool {
|
||||
return true
|
||||
}
|
||||
// match: (CMPBconst (ANDBconst _ [m]) [n])
|
||||
// cond: int8(m)+1==int8(n) && isPowerOfTwo(int64(int8(n)))
|
||||
// cond: 0 <= int8(m) && int8(m) < int8(n)
|
||||
// result: (FlagLT_ULT)
|
||||
for {
|
||||
v_0 := v.Args[0]
|
||||
@ -2249,7 +2249,7 @@ func rewriteValueAMD64_OpAMD64CMPBconst(v *Value, config *Config) bool {
|
||||
}
|
||||
m := v_0.AuxInt
|
||||
n := v.AuxInt
|
||||
if !(int8(m)+1 == int8(n) && isPowerOfTwo(int64(int8(n)))) {
|
||||
if !(0 <= int8(m) && int8(m) < int8(n)) {
|
||||
break
|
||||
}
|
||||
v.reset(OpAMD64FlagLT_ULT)
|
||||
@ -2414,7 +2414,7 @@ func rewriteValueAMD64_OpAMD64CMPLconst(v *Value, config *Config) bool {
|
||||
return true
|
||||
}
|
||||
// match: (CMPLconst (ANDLconst _ [m]) [n])
|
||||
// cond: int32(m)+1==int32(n) && isPowerOfTwo(int64(int32(n)))
|
||||
// cond: 0 <= int32(m) && int32(m) < int32(n)
|
||||
// result: (FlagLT_ULT)
|
||||
for {
|
||||
v_0 := v.Args[0]
|
||||
@ -2423,7 +2423,7 @@ func rewriteValueAMD64_OpAMD64CMPLconst(v *Value, config *Config) bool {
|
||||
}
|
||||
m := v_0.AuxInt
|
||||
n := v.AuxInt
|
||||
if !(int32(m)+1 == int32(n) && isPowerOfTwo(int64(int32(n)))) {
|
||||
if !(0 <= int32(m) && int32(m) < int32(n)) {
|
||||
break
|
||||
}
|
||||
v.reset(OpAMD64FlagLT_ULT)
|
||||
@ -2594,7 +2594,7 @@ func rewriteValueAMD64_OpAMD64CMPQconst(v *Value, config *Config) bool {
|
||||
return true
|
||||
}
|
||||
// match: (CMPQconst (ANDQconst _ [m]) [n])
|
||||
// cond: m+1==n && isPowerOfTwo(n)
|
||||
// cond: 0 <= m && m < n
|
||||
// result: (FlagLT_ULT)
|
||||
for {
|
||||
v_0 := v.Args[0]
|
||||
@ -2603,7 +2603,7 @@ func rewriteValueAMD64_OpAMD64CMPQconst(v *Value, config *Config) bool {
|
||||
}
|
||||
m := v_0.AuxInt
|
||||
n := v.AuxInt
|
||||
if !(m+1 == n && isPowerOfTwo(n)) {
|
||||
if !(0 <= m && m < n) {
|
||||
break
|
||||
}
|
||||
v.reset(OpAMD64FlagLT_ULT)
|
||||
@ -2768,7 +2768,7 @@ func rewriteValueAMD64_OpAMD64CMPWconst(v *Value, config *Config) bool {
|
||||
return true
|
||||
}
|
||||
// match: (CMPWconst (ANDWconst _ [m]) [n])
|
||||
// cond: int16(m)+1==int16(n) && isPowerOfTwo(int64(int16(n)))
|
||||
// cond: 0 <= int16(m) && int16(m) < int16(n)
|
||||
// result: (FlagLT_ULT)
|
||||
for {
|
||||
v_0 := v.Args[0]
|
||||
@ -2777,7 +2777,7 @@ func rewriteValueAMD64_OpAMD64CMPWconst(v *Value, config *Config) bool {
|
||||
}
|
||||
m := v_0.AuxInt
|
||||
n := v.AuxInt
|
||||
if !(int16(m)+1 == int16(n) && isPowerOfTwo(int64(int16(n)))) {
|
||||
if !(0 <= int16(m) && int16(m) < int16(n)) {
|
||||
break
|
||||
}
|
||||
v.reset(OpAMD64FlagLT_ULT)
|
||||
|
Loading…
Reference in New Issue
Block a user