File tree Expand file tree Collapse file tree 2 files changed +41
-4
lines changed
src/cmd/compile/internal/ssa Expand file tree Collapse file tree 2 files changed +41
-4
lines changed Original file line number Diff line number Diff line change @@ -1645,13 +1645,13 @@ func initLimit(v *Value) limit {
1645
1645
lim = lim .signedMinMax (math .MinInt32 , math .MaxInt32 )
1646
1646
1647
1647
// math/bits intrinsics
1648
- case OpCtz64 , OpBitLen64 :
1648
+ case OpCtz64 , OpBitLen64 , OpPopCount64 :
1649
1649
lim = lim .unsignedMax (64 )
1650
- case OpCtz32 , OpBitLen32 :
1650
+ case OpCtz32 , OpBitLen32 , OpPopCount32 :
1651
1651
lim = lim .unsignedMax (32 )
1652
- case OpCtz16 , OpBitLen16 :
1652
+ case OpCtz16 , OpBitLen16 , OpPopCount16 :
1653
1653
lim = lim .unsignedMax (16 )
1654
- case OpCtz8 , OpBitLen8 :
1654
+ case OpCtz8 , OpBitLen8 , OpPopCount8 :
1655
1655
lim = lim .unsignedMax (8 )
1656
1656
1657
1657
// bool to uint8 conversion
Original file line number Diff line number Diff line change
1
+ // errorcheck -0 -d=ssa/prove/debug=1
2
+
3
+ //go:build amd64.v3 || arm64
4
+
5
+ // Copyright 2025 The Go Authors. All rights reserved.
6
+ // Use of this source code is governed by a BSD-style
7
+ // license that can be found in the LICENSE file.
8
+
9
+ // FIXME(@Jorropo): this file exists because I havn't yet bothered to
10
+ // make prove work on the pure go function call fallback.
11
+ // My idea was to wait until CL 637936 is merged, then we can always emit
12
+ // the PopCount SSA operation and translate them to pure function calls
13
+ // in late-opt.
14
+
15
+ package main
16
+
17
+ import "math/bits"
18
+
19
+ func onesCountsBounds (x uint64 , ensureAllBranchesCouldHappen func () bool ) int {
20
+ z := bits .OnesCount64 (x )
21
+ if ensureAllBranchesCouldHappen () && z > 64 { // ERROR "Disproved Less64$"
22
+ return 42
23
+ }
24
+ if ensureAllBranchesCouldHappen () && z <= 64 { // ERROR "Proved Leq64$"
25
+ return 4242
26
+ }
27
+ if ensureAllBranchesCouldHappen () && z < 0 { // ERROR "Disproved Less64$"
28
+ return 424242
29
+ }
30
+ if ensureAllBranchesCouldHappen () && z >= 0 { // ERROR "Proved Leq64$"
31
+ return 42424242
32
+ }
33
+ return z
34
+ }
35
+
36
+ func main () {
37
+ }
You can’t perform that action at this time.
0 commit comments