aboutsummaryrefslogtreecommitdiff
path: root/test/codegen/arithmetic.go
diff options
context:
space:
mode:
authorJoel Sing <joel@sing.id.au>2025-02-24 23:24:42 +1100
committerJoel Sing <joel@sing.id.au>2025-03-15 06:02:57 -0700
commita8f2e63f2f5b661418f1e386e443e48356e72c40 (patch)
tree0a61710afab5d5133e20bcdddf4e44f763ca4406 /test/codegen/arithmetic.go
parente1f9013a58e5ad6d90ae0eb13a943aafa765d6e7 (diff)
downloadgo-a8f2e63f2f5b661418f1e386e443e48356e72c40.tar.xz
test/codegen: add a test for negation and conversion to int32
Codify the current code generation used on riscv64 in this case. Change-Id: If4152e3652fc19d0aa28b79dba08abee2486d5ae Reviewed-on: https://go-review.googlesource.com/c/go/+/652317 Reviewed-by: Mark Ryan <markdryan@rivosinc.com> Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'test/codegen/arithmetic.go')
-rw-r--r--test/codegen/arithmetic.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/codegen/arithmetic.go b/test/codegen/arithmetic.go
index 67bc88b587..beeb5357c4 100644
--- a/test/codegen/arithmetic.go
+++ b/test/codegen/arithmetic.go
@@ -173,6 +173,12 @@ func AddAddSubSimplify(a, b, c int) int {
return r
}
+func NegToInt32(a int) int {
+ // riscv64: "NEG","MOVW"
+ r := int(int32(-a))
+ return r
+}
+
// -------------------- //
// Multiplication //
// -------------------- //