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
7package main
8
9import "fmt"
10
11func main() {
12	testMod()
13	testMul()
14}
15
16//go:noinline
17func mod3(x uint32) uint64 {
18	return uint64(x % 3)
19}
20
21func 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
31func mul3(a uint32) uint64 {
32	return uint64(a * 3)
33}
34
35func 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}
42