Debian Codegraph @

test/codegen/generics.go

raw
1 // asmcheck
2
3 // Copyright 2025 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 codegen
8
9 import "cmp"
10
11 func isNaN[T cmp.Ordered](x T) bool {
12 return x != x
13 }
14
15 func compare[T cmp.Ordered](x, y T) int {
16 // amd64:-"TESTB"
17 // arm64:-"MOVB"
18 xNaN := isNaN(x)
19 yNaN := isNaN(y)
20 if xNaN {
21 if yNaN {
22 return 0
23 }
24 return -1
25 }
26 if yNaN {
27 return +1
28 }
29 if x < y {
30 return -1
31 }
32 if x > y {
33 return +1
34 }
35 return 0
36 }
37
38 func usesCompare(a, b int) int {
39 return compare(a, b)
40 }