From: Jorropo Date: Sun, 7 Dec 2025 02:01:17 +0000 (+0100) Subject: cmd/compile: improve Ctz's limits modeling and add bruteforce tests X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a4fda8d32ac30b787cf2c648daed7f8fe5ef859d;p=gostls13.git cmd/compile: improve Ctz's limits modeling and add bruteforce tests This make Ctz perfect within the limitations limits can represent. Change-Id: I1e596d8d01892d1b70031cf03cecc487ce147b38 Reviewed-on: https://go-review.googlesource.com/c/go/+/727780 Reviewed-by: Keith Randall Reviewed-by: Carlos Amedee Reviewed-by: Keith Randall LUCI-TryBot-Result: Go LUCI Auto-Submit: Jorropo --- diff --git a/src/cmd/compile/internal/ssa/prove.go b/src/cmd/compile/internal/ssa/prove.go index 93443a3d3c..22de2dc7a5 100644 --- a/src/cmd/compile/internal/ssa/prove.go +++ b/src/cmd/compile/internal/ssa/prove.go @@ -269,6 +269,13 @@ func convertIntWithBitsize[Target uint64 | int64, Source uint64 | int64](x Sourc } } +func (l limit) unsignedFixedLeadingBits() (fixed uint64, count uint) { + varying := uint(bits.Len64(l.umin ^ l.umax)) + count = uint(bits.LeadingZeros64(l.umin ^ l.umax)) + fixed = l.umin &^ (1<