]> Cypherpunks repositories - gostls13.git/commitdiff
test/codegen: add a test for negation and conversion to int32
authorJoel Sing <joel@sing.id.au>
Mon, 24 Feb 2025 12:24:42 +0000 (23:24 +1100)
committerJoel Sing <joel@sing.id.au>
Sat, 15 Mar 2025 13:02:57 +0000 (06:02 -0700)
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>

test/codegen/arithmetic.go

index 67bc88b5877362953f881933bf749c357e076241..beeb5357c45d91884c5f8c49f45f2f732c9e2094 100644 (file)
@@ -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    //
 // -------------------- //