aboutsummaryrefslogtreecommitdiff
path: root/test/codegen
diff options
context:
space:
mode:
authorkhr@golang.org <khr@golang.org>2024-07-11 19:38:33 -0700
committerKeith Randall <khr@golang.org>2024-08-07 16:08:20 +0000
commit9b4268c3df9dcc46a7185a6095ea6e2e685ace66 (patch)
tree7881f5276d446f09d49c72ab7cc62964bc61aa0e /test/codegen
parentaba16d17c5c674416a322c16f8baba063fafa988 (diff)
downloadgo-9b4268c3df9dcc46a7185a6095ea6e2e685ace66.tar.xz
cmd/compile: simplify prove pass
We don't need noLimit checks in a bunch of places. Also simplify folding of provable constant results. At this point in the CL stack, compilebench reports no performance changes. The only thing of note is that binaries got a bit smaller. name old text-bytes new text-bytes delta HelloSize 960kB ± 0% 952kB ± 0% -0.83% (p=0.000 n=10+10) CmdGoSize 12.3MB ± 0% 12.1MB ± 0% -1.53% (p=0.000 n=10+10) Change-Id: Id4be75eec0f8c93f2f3b93a8521ce2278ee2ee2c Reviewed-on: https://go-review.googlesource.com/c/go/+/599197 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'test/codegen')
-rw-r--r--test/codegen/bool.go43
-rw-r--r--test/codegen/writebarrier.go10
2 files changed, 35 insertions, 18 deletions
diff --git a/test/codegen/bool.go b/test/codegen/bool.go
index 990a9ed1b1..0daeb88b9b 100644
--- a/test/codegen/bool.go
+++ b/test/codegen/bool.go
@@ -217,53 +217,53 @@ func TestSetInvGeFp64(x float64, y float64) bool {
}
func TestLogicalCompareZero(x *[64]uint64) {
// ppc64x:"ANDCC",^"AND"
- b := x[0]&3
- if b!=0 {
+ b := x[0] & 3
+ if b != 0 {
x[0] = b
}
// ppc64x:"ANDCC",^"AND"
- b = x[1]&x[2]
- if b!=0 {
+ b = x[1] & x[2]
+ if b != 0 {
x[1] = b
}
// ppc64x:"ANDNCC",^"ANDN"
- b = x[1]&^x[2]
- if b!=0 {
+ b = x[1] &^ x[2]
+ if b != 0 {
x[1] = b
}
// ppc64x:"ORCC",^"OR"
- b = x[3]|x[4]
- if b!=0 {
+ b = x[3] | x[4]
+ if b != 0 {
x[3] = b
}
// ppc64x:"SUBCC",^"SUB"
- b = x[5]-x[6]
- if b!=0 {
+ b = x[5] - x[6]
+ if b != 0 {
x[5] = b
}
// ppc64x:"NORCC",^"NOR"
- b = ^(x[5]|x[6])
- if b!=0 {
+ b = ^(x[5] | x[6])
+ if b != 0 {
x[5] = b
}
// ppc64x:"XORCC",^"XOR"
- b = x[7]^x[8]
- if b!=0 {
+ b = x[7] ^ x[8]
+ if b != 0 {
x[7] = b
}
// ppc64x:"ADDCC",^"ADD"
- b = x[9]+x[10]
- if b!=0 {
+ b = x[9] + x[10]
+ if b != 0 {
x[9] = b
}
// ppc64x:"NEGCC",^"NEG"
b = -x[11]
- if b!=0 {
+ if b != 0 {
x[11] = b
}
// ppc64x:"CNTLZDCC",^"CNTLZD"
b = uint64(bits.LeadingZeros64(x[12]))
- if b!=0 {
+ if b != 0 {
x[12] = b
}
@@ -274,3 +274,10 @@ func TestLogicalCompareZero(x *[64]uint64) {
}
}
+
+func constantWrite(b bool, p *bool) {
+ if b {
+ // amd64:`MOVB\t[$]1, \(`
+ *p = b
+ }
+}
diff --git a/test/codegen/writebarrier.go b/test/codegen/writebarrier.go
index cfcfe15a40..e125973e7c 100644
--- a/test/codegen/writebarrier.go
+++ b/test/codegen/writebarrier.go
@@ -53,3 +53,13 @@ func combine4slice(p *[4][]byte, a, b, c, d []byte) {
// arm64:-`.*runtime[.]gcWriteBarrier`
p[3] = d
}
+
+func trickyWriteNil(p *int, q **int) {
+ if p == nil {
+ // We change "= p" to "= 0" in the prove pass, which
+ // means we have one less pointer that needs to go
+ // into the write barrier buffer.
+ // amd64:`.*runtime[.]gcWriteBarrier1`
+ *q = p
+ }
+}