Commit 548e1f89 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

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 <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarGiovanni Bajo <rasky@develer.com>
parent 31cfa7f2
...@@ -1068,6 +1068,10 @@ func isNonNegative(v *Value) bool { ...@@ -1068,6 +1068,10 @@ func isNonNegative(v *Value) bool {
OpZeroExt8to64, OpZeroExt16to64, OpZeroExt32to64: OpZeroExt8to64, OpZeroExt16to64, OpZeroExt32to64:
return true return true
case OpRsh64Ux64:
by := v.Args[1]
return by.Op == OpConst64 && by.AuxInt > 0
case OpRsh64x64: case OpRsh64x64:
return isNonNegative(v.Args[0]) return isNonNegative(v.Args[0])
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment