Debian Codegraph @

test/fixedbugs/issue66066.go

raw
1 // run
2
3 // Copyright 2024 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6
7 package main
8
9 import "fmt"
10
11 func main() {
12 testMod()
13 testMul()
14 }
15
16 //go:noinline
17 func mod3(x uint32) uint64 {
18 return uint64(x % 3)
19 }
20
21 func testMod() {
22 got := mod3(1<<32 - 1)
23 want := uint64((1<<32 - 1) % 3)
24 if got != want {
25 fmt.Printf("testMod: got %x want %x\n", got, want)
26 }
27
28 }
29
30 //go:noinline
31 func mul3(a uint32) uint64 {
32 return uint64(a * 3)
33 }
34
35 func testMul() {
36 got := mul3(1<<32 - 1)
37 want := uint64((1<<32-1)*3 - 2<<32)
38 if got != want {
39 fmt.Printf("testMul: got %x want %x\n", got, want)
40 }
41 }