]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fold constants found by prove
authorJorropo <jorropo.pgm@gmail.com>
Wed, 4 May 2022 17:03:13 +0000 (17:03 +0000)
committerKeith Randall <khr@golang.org>
Wed, 4 May 2022 20:30:17 +0000 (20:30 +0000)
commite1e056fa6a2f788a15e17d55b7953712053fd760
tree42d05f45e9175d6b13856b82833c3e9f1a0a3bc2
parentfbb47e81c1f24a8b9cb84430e9561ace60580af1
cmd/compile: fold constants found by prove

It is hit ~70k times building go.
This make the go binary, 0.04% smaller.
I didn't included benchmarks because this is just constant foldings
and is hard to mesure objectively.

For example, this enable rewriting things like:
  if x == 20 {
    return x + 30 + z
  }

Into:
  if x == 20 {
    return 50 + z
  }

It's not just fixing programer's code,
the ssa generator generate code like this sometimes.

Change-Id: I0861f342b27f7227b5f1c34d8267fa0057b1bbbc
GitHub-Last-Rev: 4c2f9b521692bc61acff137a269917895f4da08a
GitHub-Pull-Request: golang/go#52669
Reviewed-on: https://go-review.googlesource.com/c/go/+/403735
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/ssa/prove.go
test/codegen/comparisons.go
test/prove_constant_folding.go [new file with mode: 0644]