From: Jorropo Date: Mon, 10 Mar 2025 05:44:38 +0000 (+0100) Subject: cmd/compile: compute bitsize from type size in prove to clean some switches X-Git-Tag: go1.25rc1~742 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=644b984027d11d43881507a938b28ed9df3b3320;p=gostls13.git cmd/compile: compute bitsize from type size in prove to clean some switches Change-Id: I215adda9050d214576433700aed4c371a36aaaed Reviewed-on: https://go-review.googlesource.com/c/go/+/656335 Reviewed-by: Keith Randall LUCI-TryBot-Result: Go LUCI Reviewed-by: David Chase Reviewed-by: Keith Randall Auto-Submit: Jorropo --- diff --git a/src/cmd/compile/internal/ssa/prove.go b/src/cmd/compile/internal/ssa/prove.go index 1b5989e6e5..acbba2b27a 100644 --- a/src/cmd/compile/internal/ssa/prove.go +++ b/src/cmd/compile/internal/ssa/prove.go @@ -1601,19 +1601,8 @@ func initLimit(v *Value) limit { } // Default limits based on type. - var lim limit - switch v.Type.Size() { - case 8: - lim = limit{min: math.MinInt64, max: math.MaxInt64, umin: 0, umax: math.MaxUint64} - case 4: - lim = limit{min: math.MinInt32, max: math.MaxInt32, umin: 0, umax: math.MaxUint32} - case 2: - lim = limit{min: math.MinInt16, max: math.MaxInt16, umin: 0, umax: math.MaxUint16} - case 1: - lim = limit{min: math.MinInt8, max: math.MaxInt8, umin: 0, umax: math.MaxUint8} - default: - panic("bad") - } + bitsize := v.Type.Size() * 8 + lim := limit{min: -(1 << (bitsize - 1)), max: 1<<(bitsize-1) - 1, umin: 0, umax: 1<