diff options
author | Daniel Martà <mvdan@mvdan.cc> | 2019-03-13 11:57:29 +0000 |
---|---|---|
committer | Daniel Martà <mvdan@mvdan.cc> | 2019-03-22 15:41:51 +0000 |
commit | 0fbf6818407366d79a7a388b58718f6c32ef16d2 (patch) | |
tree | 0f77bd0051e176e7fa09fcefe78df6f1e1a8a7fe /src/cmd/compile/internal/ssa/rewriteAMD64splitload.go | |
parent | b06d2122eec394a044d7b04a011b5b79318dc4c0 (diff) | |
download | go-0fbf6818407366d79a7a388b58718f6c32ef16d2.tar.gz go-0fbf6818407366d79a7a388b58718f6c32ef16d2.zip |
cmd/compile: reduce rulegen's for loop verbosity
A lot of the naked for loops begin like:
for {
v := b.Control
if v.Op != OpConstBool {
break
}
...
return true
}
Instead, write them out in a more compact and readable way:
for v.Op == OpConstBool {
...
return true
}
This requires the addition of two bytes.Buffer writers, as this helps us
make a decision based on future pieces of generated code. This probably
makes rulegen slightly slower, but that's not noticeable; the code
generation still takes ~3.5s on my laptop, excluding build time.
The "v := b.Control" declaration can be moved to the top of each
function. Even though the rules can modify b.Control when firing, they
also make the function return, so v can't be used again.
While at it, remove three unnecessary lines from the top of each
rewriteBlock func.
In total, this results in ~4k lines removed from the generated code, and
a slight improvement in readability.
Change-Id: I317e4c6a4842c64df506f4513375475fad2aeec5
Reviewed-on: https://go-review.googlesource.com/c/go/+/167399
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/rewriteAMD64splitload.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/rewriteAMD64splitload.go | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/ssa/rewriteAMD64splitload.go b/src/cmd/compile/internal/ssa/rewriteAMD64splitload.go index dbd0e031a4..0a0ff2dfbf 100644 --- a/src/cmd/compile/internal/ssa/rewriteAMD64splitload.go +++ b/src/cmd/compile/internal/ssa/rewriteAMD64splitload.go @@ -218,11 +218,10 @@ func rewriteValueAMD64splitload_OpAMD64CMPWload_0(v *Value) bool { } func rewriteBlockAMD64splitload(b *Block) bool { config := b.Func.Config - _ = config - fe := b.Func.fe - _ = fe typ := &config.Types _ = typ + v := b.Control + _ = v switch b.Kind { } return false |