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>
// 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)
+}