aboutsummaryrefslogtreecommitdiff
path: root/test/codegen/arithmetic.go
diff options
context:
space:
mode:
authorJoel Sing <joel@sing.id.au>2025-02-24 23:08:46 +1100
committerJoel Sing <joel@sing.id.au>2025-03-15 06:02:27 -0700
commite1f9013a58e5ad6d90ae0eb13a943aafa765d6e7 (patch)
tree57fea6ad49a57833209bfc1dcf5b68a0f25b73b3 /test/codegen/arithmetic.go
parentc01fa0cc21caf2fee9b04154e5ee83cbc239cc98 (diff)
downloadgo-e1f9013a58e5ad6d90ae0eb13a943aafa765d6e7.tar.xz
test/codegen: add riscv64 codegen for arithmetic tests
Codify the current riscv64 code generation for various subtract from constant and addition/subtraction tests. Change-Id: I54ad923280a0578a338bc4431fa5bdc0644c4729 Reviewed-on: https://go-review.googlesource.com/c/go/+/652316 Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mark Ryan <markdryan@rivosinc.com> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'test/codegen/arithmetic.go')
-rw-r--r--test/codegen/arithmetic.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/codegen/arithmetic.go b/test/codegen/arithmetic.go
index f09af769f5..67bc88b587 100644
--- a/test/codegen/arithmetic.go
+++ b/test/codegen/arithmetic.go
@@ -85,36 +85,42 @@ func SubMem(arr []int, b, c, d int) int {
func SubFromConst(a int) int {
// ppc64x: `SUBC\tR[0-9]+,\s[$]40,\sR`
+ // riscv64: "ADDI\t\\$-40","NEG"
b := 40 - a
return b
}
func SubFromConstNeg(a int) int {
// ppc64x: `ADD\t[$]40,\sR[0-9]+,\sR`
+ // riscv64: "NEG","ADDI\t\\$-40","NEG"
c := 40 - (-a)
return c
}
func SubSubFromConst(a int) int {
// ppc64x: `ADD\t[$]20,\sR[0-9]+,\sR`
+ // riscv64: "ADDI\t\\$20",-"NEG"
c := 40 - (20 - a)
return c
}
func AddSubFromConst(a int) int {
// ppc64x: `SUBC\tR[0-9]+,\s[$]60,\sR`
+ // riscv64: "ADDI\t\\$-60","NEG"
c := 40 + (20 - a)
return c
}
func NegSubFromConst(a int) int {
// ppc64x: `ADD\t[$]-20,\sR[0-9]+,\sR`
+ // riscv64: "ADDI\t\\$-20"
c := -(20 - a)
return c
}
func NegAddFromConstNeg(a int) int {
// ppc64x: `SUBC\tR[0-9]+,\s[$]40,\sR`
+ // riscv64: "ADDI\t\\$-40","NEG"
c := -(-40 + a)
return c
}
@@ -122,6 +128,7 @@ func NegAddFromConstNeg(a int) int {
func SubSubNegSimplify(a, b int) int {
// amd64:"NEGQ"
// ppc64x:"NEG"
+ // riscv64:"NEG",-"SUB"
r := (a - b) - a
return r
}
@@ -129,6 +136,7 @@ func SubSubNegSimplify(a, b int) int {
func SubAddSimplify(a, b int) int {
// amd64:-"SUBQ",-"ADDQ"
// ppc64x:-"SUB",-"ADD"
+ // riscv64:-"SUB",-"ADD"
r := a + (b - a)
return r
}
@@ -152,6 +160,7 @@ func SubAddSimplify2(a, b, c int) (int, int, int, int, int, int) {
func SubAddNegSimplify(a, b int) int {
// amd64:"NEGQ",-"ADDQ",-"SUBQ"
// ppc64x:"NEG",-"ADD",-"SUB"
+ // riscv64:"NEG",-"ADD",-"SUB"
r := a - (b + a)
return r
}
@@ -159,6 +168,7 @@ func SubAddNegSimplify(a, b int) int {
func AddAddSubSimplify(a, b, c int) int {
// amd64:-"SUBQ"
// ppc64x:-"SUB"
+ // riscv64:"ADD","ADD",-"SUB"
r := a + (b + (c - a))
return r
}