mirror of
https://github.com/golang/go
synced 2024-11-17 21:04:43 -07:00
cmd/compile: int64(uint64 >> x) >= 0 if x > 0
This rewrite rule triggers only once, in math/big.quotToFloat64, as part of converting a uint64 to a float64. Nevertheless, it is cheap; let's add it. Change-Id: I3ed4a197a559110fec1bc04b3a8abb4c7fcc2c89 Reviewed-on: https://go-review.googlesource.com/c/go/+/167500 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
61945fc502
commit
66f5d4e035
@ -425,6 +425,8 @@
|
||||
(Geq32 (And32 _ (Const32 [c])) (Const32 [0])) && int32(c) >= 0 -> (ConstBool [1])
|
||||
(Geq64 (And64 _ (Const64 [c])) (Const64 [0])) && int64(c) >= 0 -> (ConstBool [1])
|
||||
|
||||
(Geq64 (Rsh64Ux64 _ (Const64 [c])) (Const64 [0])) && c > 0 -> (ConstBool [1])
|
||||
|
||||
(Greater64U (Const64 [c]) (Const64 [d])) -> (ConstBool [b2i(uint64(c) > uint64(d))])
|
||||
(Greater32U (Const32 [c]) (Const32 [d])) -> (ConstBool [b2i(uint32(c) > uint32(d))])
|
||||
(Greater16U (Const16 [c]) (Const16 [d])) -> (ConstBool [b2i(uint16(c) > uint16(d))])
|
||||
|
@ -10714,6 +10714,35 @@ func rewriteValuegeneric_OpGeq64_0(v *Value) bool {
|
||||
v.AuxInt = 1
|
||||
return true
|
||||
}
|
||||
// match: (Geq64 (Rsh64Ux64 _ (Const64 [c])) (Const64 [0]))
|
||||
// cond: c > 0
|
||||
// result: (ConstBool [1])
|
||||
for {
|
||||
_ = v.Args[1]
|
||||
v_0 := v.Args[0]
|
||||
if v_0.Op != OpRsh64Ux64 {
|
||||
break
|
||||
}
|
||||
_ = v_0.Args[1]
|
||||
v_0_1 := v_0.Args[1]
|
||||
if v_0_1.Op != OpConst64 {
|
||||
break
|
||||
}
|
||||
c := v_0_1.AuxInt
|
||||
v_1 := v.Args[1]
|
||||
if v_1.Op != OpConst64 {
|
||||
break
|
||||
}
|
||||
if v_1.AuxInt != 0 {
|
||||
break
|
||||
}
|
||||
if !(c > 0) {
|
||||
break
|
||||
}
|
||||
v.reset(OpConstBool)
|
||||
v.AuxInt = 1
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
func rewriteValuegeneric_OpGeq64F_0(v *Value) bool {
|
||||
|
Loading…
Reference in New Issue
Block a user