From: Josh Bleecher Snyder Date: Wed, 25 Apr 2018 20:17:17 +0000 (-0700) Subject: cmd/compile: recognize some OpRsh64Ux64 Values as non-negative X-Git-Tag: go1.11beta1~576 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=548e1f89363fd3054a0bd8961c6c6b8b8ecbcfaf;p=gostls13.git cmd/compile: recognize some OpRsh64Ux64 Values as non-negative Proves IsSliceInBounds one additional time building std+cmd, at encoding/hex/hex.go:187:8. The code is: if numAvail := len(d.in) / 2; len(p) > numAvail { p = p[:numAvail] } Previously we were unable to prove that numAvail >= 0. Change-Id: Ie74e0aef809f9194c45e129ee3dae60bc3eae02f Reviewed-on: https://go-review.googlesource.com/109415 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Giovanni Bajo --- diff --git a/src/cmd/compile/internal/ssa/prove.go b/src/cmd/compile/internal/ssa/prove.go index 03f657da8a..b30dab9fe3 100644 --- a/src/cmd/compile/internal/ssa/prove.go +++ b/src/cmd/compile/internal/ssa/prove.go @@ -1068,6 +1068,10 @@ func isNonNegative(v *Value) bool { OpZeroExt8to64, OpZeroExt16to64, OpZeroExt32to64: return true + case OpRsh64Ux64: + by := v.Args[1] + return by.Op == OpConst64 && by.AuxInt > 0 + case OpRsh64x64: return isNonNegative(v.Args[0]) }