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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Keith Randall <khr@google.com>
This commit is contained in:
Keith Randall 2025-11-17 22:40:26 -08:00
parent 8806d53c10
commit ba634ca5c7
3 changed files with 48 additions and 0 deletions

View file

@ -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
}