From ba634ca5c7f19105c853db5752cc0f6d3ca76e45 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Mon, 17 Nov 2025 22:40:26 -0800 Subject: cmd/compile: fold boolean NOT into branches Gets rid of an EOR $1 instruction. Change-Id: Ib032b0cee9ac484329c978af9b1305446f8d5dac Reviewed-on: https://go-review.googlesource.com/c/go/+/721501 LUCI-TryBot-Result: Go LUCI Reviewed-by: Junyang Shao Reviewed-by: Keith Randall --- test/codegen/bool.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/codegen') diff --git a/test/codegen/bool.go b/test/codegen/bool.go index 37f85a45b7..8fe7a94687 100644 --- a/test/codegen/bool.go +++ b/test/codegen/bool.go @@ -313,3 +313,18 @@ func constantWrite(b bool, p *bool) { *p = b } } + +func boolCompare1(p, q *bool) int { + // arm64:-"EOR [$]1" + if *p == *q { + return 5 + } + return 7 +} +func boolCompare2(p, q *bool) int { + // arm64:-"EOR [$]1" + if *p != *q { + return 5 + } + return 7 +} -- cgit v1.3