mirror of https://github.com/golang/go.git
9 Commits
| Author | SHA1 | Message | Date |
|---|---|---|---|
|
|
c9d0fad5cb |
cmd/compile: add 2 phiopt cases
Add 2 more cases:
if a { x = value } else { x = a } => x = a && value
if a { x = a } else { x = value } => x = a || value
AND case goes from:
00006 (8) TESTB AX, AX
00007 (8) JNE 9
00008 (13) MOVL AX, BX
00009 (13) MOVL BX, AX
00010 (13) RET
to:
00006 (13) ANDL BX, AX
00007 (13) RET
OR goes from:
00006 (19) TESTB AX, AX
00007 (19) JNE 9
00008 (24) MOVL BX, AX
00009 (24) RET
to:
00006 (24) ORL BX, AX
00007 (24) RET
compilecmp linux/amd64:
runtime
runtime.lock2 847 -> 869 (+2.60%)
runtime.addspecial 542 -> 517 (-4.61%)
runtime.tracebackPCs changed
runtime.scanstack changed
runtime.mallocinit changed
runtime.traceback2 2238 -> 2206 (-1.43%)
runtime [cmd/compile]
runtime.lock2 860 -> 882 (+2.56%)
runtime.scanstack changed
runtime.addspecial 542 -> 517 (-4.61%)
runtime.traceback2 2238 -> 2206 (-1.43%)
runtime.lockWithRank 870 -> 890 (+2.30%)
runtime.tracebackPCs changed
runtime.mallocinit changed
strconv
strconv.ryuFtoaFixed32 changed
strconv.ryuFtoaFixed64 639 -> 638 (-0.16%)
strconv.readFloat changed
strconv.ryuFtoaShortest changed
strings
strings.(*Replacer).build changed
strconv [cmd/compile]
strconv.readFloat changed
strconv.ryuFtoaFixed64 639 -> 638 (-0.16%)
strconv.ryuFtoaFixed32 changed
strconv.ryuFtoaShortest changed
strings [cmd/compile]
strings.(*Replacer).build changed
regexp
regexp.makeOnePass.func1 changed
regexp [cmd/compile]
regexp.makeOnePass.func1 changed
encoding/json
encoding/json.indirect changed
database/sql
database/sql.driverArgsConnLocked changed
vendor/golang.org/x/text/unicode/norm
vendor/golang.org/x/text/unicode/norm.Form.transform changed
go/doc/comment
go/doc/comment.parseSpans changed
internal/diff
internal/diff.tgs changed
log/slog
log/slog.(*handleState).appendNonBuiltIns 1898 -> 1877 (-1.11%)
testing/fstest
testing/fstest.(*fsTester).checkGlob changed
runtime/pprof
runtime/pprof.(*profileBuilder).build changed
cmd/internal/dwarf
cmd/internal/dwarf.isEmptyInlinedCall 254 -> 244 (-3.94%)
go/printer
go/printer.keepTypeColumn 302 -> 270 (-10.60%)
go/printer.(*printer).binaryExpr changed
cmd/compile/internal/syntax
cmd/compile/internal/syntax.(*scanner).rune changed
cmd/compile/internal/syntax.(*scanner).number 2137 -> 2153 (+0.75%)
Change-Id: I7f95f54b03a35d0b616c40f38b415a7feb71be73
Reviewed-on: https://go-review.googlesource.com/c/go/+/666835
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Jakub Ciolek <jakub@ciolek.dev>
TryBot-Bypass: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
|
|
|
|
b2fd76ab8d |
test: migrate remaining files to go:build syntax
Most of the test cases in the test directory use the new go:build syntax already. Convert the rest. In general, try to place the build constraint line below the test directive comment in more places. For #41184. For #60268. Change-Id: I11c41a0642a8a26dc2eda1406da908645bbc005b Cq-Include-Trybots: luci.golang.try:gotip-linux-386-longtest,gotip-linux-amd64-longtest,gotip-windows-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/536236 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> |
|
|
|
ba6bd967d2 |
cmd/compile/internal/ssa: strengthen phiopt pass
The current phiopt pass just transforms the following code
x := false
if b { x = true}
into
x = b
But we find code in runtime.atoi like this:
neg := false
if s[0] == '-' {
neg = true
s = s[1:]
}
The current phiopt pass does not covert it into code like:
neg := s[0] == '-'
if neg { s = s[1:] }
Therefore, this patch strengthens the phiopt pass so that the
boolean Phi value "neg" can be replaced with a copy of control
value "s[0] == '-'", thereby using "cmp+cset" instead of a branch.
But in some cases even replacing the boolean Phis cannot eliminate
this branch. In the following case, this patch replaces "d" with a
copy of "a<0", but the regalloc pass will insert the "Load {c}"
value into an empty block to split the live ranges, which causes
the branch to not be eliminated.
For example:
func test(a, b, c int) (bool, int) {
d := false
if (a<0) {
if (b<0) {
c = c+1
}
d = true
}
return d, c
}
The optimized assembly code:
MOVD "".a(FP), R0
TBZ $63, R0, 48
MOVD "".c+16(FP), R1
ADD $1, R1, R2
MOVD "".b+8(FP), R3
CMP ZR, R3
CSEL LT, R2, R1, R1
CMP ZR, R0
CSET LT, R0
MOVB R0, "".~r3+24(FP)
MOVD R1, "".~r4+32(FP)
RET (R30)
MOVD "".c+16(FP), R1
JMP 28
The benchmark:
name old time/op new time/op delta
pkg:cmd/compile/internal/ssa goos:linux goarch:arm64
PhioptPass 117783.250000ns +- 1% 117219.111111ns +- 1% ~ (p=0.074 n=8+9)
Statistical data from compilecmp tool:
compilecmp local/master -> HEAD
local/master (
|
|
|
|
7e2b5a102e |
test: re-enable phi optimization test
CL 28978 (
|
|
|
|
6ec993adc3 |
cmd/compile: add SSA backend for s390x and enable by default
The new SSA backend modifies the ABI slightly: R0 is now a usable general purpose register. Fixes #16677. Change-Id: I367435ce921e0c7e79e021c80cf8ef5d1d1466cf Reviewed-on: https://go-review.googlesource.com/28978 Run-TryBot: Michael Munday <munday@ca.ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> |
|
|
|
8b92397bcd |
cmd/compile: introduce bool operations.
Introduce OrB, EqB, NeqB, AndB to handle bool operations. Change-Id: I53e4d5125a8090d5eeb4576db619103f19fff58d Reviewed-on: https://go-review.googlesource.com/22412 Reviewed-by: Keith Randall <khr@golang.org> |
|
|
|
caef4496fc |
cmd/compile: convert some Phis into And8.
See discussion at [1]. True value must have a fixed non-zero representation meaning that a && b can be implemented as a & b. [1] https://groups.google.com/forum/#!topic/golang-dev/xV0vPuFP9Vg This change helps with m := a && b, but it's more common to see if a && b { do something } which is not handled. Change-Id: Ib6f9ff898a0a8c05d12466e2464e4fe781035394 Reviewed-on: https://go-review.googlesource.com/22313 Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> |
|
|
|
8b20fd000d |
cmd/compile: transform some Phis into Or8.
func f(a, b bool) bool {
return a || b
}
is now a single instructions (excluding loading and unloading the arguments):
v10 = ORB <bool> v11 v12 : AX
Change-Id: Iff63399410cb46909f4318ea1c3f45a029f4aa5e
Reviewed-on: https://go-review.googlesource.com/21872
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
|
|
|
|
e197f467d5 |
[dev.ssa] cmd/compile/internal/ssa: simplify boolean phis
* Decreases the generated code slightly. * Similar to phiopt pass from gcc, except it only handles booleans. Handling Eq/Neq had no impact on the generated code. name old time/op new time/op delta Template 453ms ± 4% 451ms ± 4% ~ (p=0.468 n=24+24) GoTypes 1.55s ± 1% 1.55s ± 2% ~ (p=0.287 n=24+25) Compiler 6.53s ± 2% 6.56s ± 1% +0.46% (p=0.050 n=23+23) MakeBash 45.8s ± 2% 45.7s ± 2% ~ (p=0.866 n=24+25) name old text-bytes new text-bytes delta HelloSize 676k ± 0% 676k ± 0% ~ (all samples are equal) CmdGoSize 8.07M ± 0% 8.07M ± 0% -0.03% (p=0.000 n=25+25) Change-Id: Ia62477b7554127958a14cb27f85849b095d63663 Reviewed-on: https://go-review.googlesource.com/20090 Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro> TryBot-Result: Gobot Gobot <gobot@golang.org> |