]> Cypherpunks repositories - gostls13.git/commitdiff
test/codegen: add bitwise operation combination tests
authorXiaolin Zhao <zhaoxiaolin@loongson.cn>
Thu, 15 Jan 2026 08:30:30 +0000 (16:30 +0800)
committerabner chenc <chenguoqi@loongson.cn>
Fri, 30 Jan 2026 00:48:45 +0000 (16:48 -0800)
This commit adds two test functions, bitsOptXor1 and bitsOptXor2,
to verify that the compiler correctly optimizes certain bitwise
expression patterns in future CLs.

Change-Id: Idf5bd1ff8653f8fa218604d857639e063546d8e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/736540
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

test/codegen/bits.go

index d9c567b0784695c745ea32a541d8246a8d1c1f92..98489e321197d0f3c84cd15eeb029c22d8c30df4 100644 (file)
@@ -563,3 +563,15 @@ func bitsRotateAndMask(io64 [8]uint64, io32 [4]uint32, io16 [4]uint16, io8 [4]ui
        // ppc64x: "ANDCC [$]120"
        io8[0] = io8[0] & uint8(bigc)
 }
+
+func bitsOpXor1(x, y uint32) uint32 {
+       // arm64: "ORR" "AND" "BIC"
+       // loong64: "OR " "AND " "ANDN"
+       return (x | y) &^ (x & y)
+}
+
+func bitsOpXor2(x, y uint32) uint32 {
+       // arm64: "BIC" "ORR"
+       // loong64: "ANDN" "OR "
+       return (x &^ y) | (^x & y)
+}