Skip to content

Commit 02a9f51

Browse files
committed
test/codegen: add initial codegen tests for integer min/max
Change-Id: I006370053748edbec930c7279ee88a805009aa0d Reviewed-on: https://go-review.googlesource.com/c/go/+/606976 Reviewed-by: Cherry Mui <[email protected]> Reviewed-by: Meng Zhuo <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 1e9c5bb commit 02a9f51

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/codegen/arithmetic.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,3 +629,39 @@ func constantFold3(i, j int) int {
629629
r := (5 * i) * (6 * j)
630630
return r
631631
}
632+
633+
// ----------------- //
634+
// Integer Min/Max //
635+
// ----------------- //
636+
637+
func Int64Min(a, b int64) int64 {
638+
// amd64: "CMPQ","CMOVQLT"
639+
// arm64: "CMP","CSEL"
640+
// riscv64/rva20u64:"BLT\t"
641+
// riscv64/rva22u64:"MIN\t"
642+
return min(a, b)
643+
}
644+
645+
func Int64Max(a, b int64) int64 {
646+
// amd64: "CMPQ","CMOVQGT"
647+
// arm64: "CMP","CSEL"
648+
// riscv64/rva20u64:"BLT\t"
649+
// riscv64/rva22u64:"MAX\t"
650+
return max(a, b)
651+
}
652+
653+
func Uint64Min(a, b uint64) uint64 {
654+
// amd64: "CMPQ","CMOVQCS"
655+
// arm64: "CMP","CSEL"
656+
// riscv64/rva20u64:"BLTU"
657+
// riscv64/rva22u64:"MINU"
658+
return min(a, b)
659+
}
660+
661+
func Uint64Max(a, b uint64) uint64 {
662+
// amd64: "CMPQ","CMOVQHI"
663+
// arm64: "CMP","CSEL"
664+
// riscv64/rva20u64:"BLTU"
665+
// riscv64/rva22u64:"MAXU"
666+
return max(a, b)
667+
}

0 commit comments

Comments
 (0)