aboutsummaryrefslogtreecommitdiff
path: root/test/codegen
diff options
context:
space:
mode:
authorJoel Sing <joel@sing.id.au>2024-08-20 23:41:40 +1000
committerJoel Sing <joel@sing.id.au>2024-08-23 15:17:17 +0000
commit02a9f51011eb7b6150828aab623eede497eb1e09 (patch)
tree886fd4839f9ec029851d40ea7b12748e8b428064 /test/codegen
parent1e9c5bbc8a428da5832137e84d08ff2b8e99dfaa (diff)
downloadgo-02a9f51011eb7b6150828aab623eede497eb1e09.tar.xz
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 <cherryyz@google.com> Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'test/codegen')
-rw-r--r--test/codegen/arithmetic.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/codegen/arithmetic.go b/test/codegen/arithmetic.go
index e474a10ba2..4b47f6c13d 100644
--- a/test/codegen/arithmetic.go
+++ b/test/codegen/arithmetic.go
@@ -629,3 +629,39 @@ func constantFold3(i, j int) int {
r := (5 * i) * (6 * j)
return r
}
+
+// ----------------- //
+// Integer Min/Max //
+// ----------------- //
+
+func Int64Min(a, b int64) int64 {
+ // amd64: "CMPQ","CMOVQLT"
+ // arm64: "CMP","CSEL"
+ // riscv64/rva20u64:"BLT\t"
+ // riscv64/rva22u64:"MIN\t"
+ return min(a, b)
+}
+
+func Int64Max(a, b int64) int64 {
+ // amd64: "CMPQ","CMOVQGT"
+ // arm64: "CMP","CSEL"
+ // riscv64/rva20u64:"BLT\t"
+ // riscv64/rva22u64:"MAX\t"
+ return max(a, b)
+}
+
+func Uint64Min(a, b uint64) uint64 {
+ // amd64: "CMPQ","CMOVQCS"
+ // arm64: "CMP","CSEL"
+ // riscv64/rva20u64:"BLTU"
+ // riscv64/rva22u64:"MINU"
+ return min(a, b)
+}
+
+func Uint64Max(a, b uint64) uint64 {
+ // amd64: "CMPQ","CMOVQHI"
+ // arm64: "CMP","CSEL"
+ // riscv64/rva20u64:"BLTU"
+ // riscv64/rva22u64:"MAXU"
+ return max(a, b)
+}