1
0
mirror of https://github.com/golang/go synced 2024-11-23 18:00:06 -07:00
The Go programming language
Go to file
Josh Bleecher Snyder c1544ff906 cmd/compile: move phi tighten after critical
The phi tighten pass moves rematerializable phi args
to the immediate predecessor of the phis.
This reduces value lifetimes for regalloc.

However, the critical edge removal pass can introduce
new blocks, which can change what a block's
immediate precedessor is. This can result in tightened
phi args being spilled unnecessarily.

This change moves the phi tighten pass after the
critical edge pass, when the block structure is stable.

This improves the code generated for

func f(s string) bool { return s == "abcde" }

Before this change:

"".f STEXT nosplit size=44 args=0x18 locals=0x0
	0x0000 00000 (x.go:3)	MOVQ	"".s+16(SP), AX
	0x0005 00005 (x.go:3)	CMPQ	AX, $5
	0x0009 00009 (x.go:3)	JNE	40
	0x000b 00011 (x.go:3)	MOVQ	"".s+8(SP), AX
	0x0010 00016 (x.go:3)	CMPL	(AX), $1684234849
	0x0016 00022 (x.go:3)	JNE	36
	0x0018 00024 (x.go:3)	CMPB	4(AX), $101
	0x001c 00028 (x.go:3)	SETEQ	AL
	0x001f 00031 (x.go:3)	MOVB	AL, "".~r1+24(SP)
	0x0023 00035 (x.go:3)	RET
	0x0024 00036 (x.go:3)	XORL	AX, AX
	0x0026 00038 (x.go:3)	JMP	31
	0x0028 00040 (x.go:3)	XORL	AX, AX
	0x002a 00042 (x.go:3)	JMP	31

Observe the duplicated blocks at the end.
After this change:

"".f STEXT nosplit size=40 args=0x18 locals=0x0
	0x0000 00000 (x.go:3)	MOVQ	"".s+16(SP), AX
	0x0005 00005 (x.go:3)	CMPQ	AX, $5
	0x0009 00009 (x.go:3)	JNE	36
	0x000b 00011 (x.go:3)	MOVQ	"".s+8(SP), AX
	0x0010 00016 (x.go:3)	CMPL	(AX), $1684234849
	0x0016 00022 (x.go:3)	JNE	36
	0x0018 00024 (x.go:3)	CMPB	4(AX), $101
	0x001c 00028 (x.go:3)	SETEQ	AL
	0x001f 00031 (x.go:3)	MOVB	AL, "".~r1+24(SP)
	0x0023 00035 (x.go:3)	RET
	0x0024 00036 (x.go:3)	XORL	AX, AX
	0x0026 00038 (x.go:3)	JMP	31

Change-Id: I12c81aa53b89456cb5809aa5396378245f3beda9
Reviewed-on: https://go-review.googlesource.com/c/go/+/172597
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-04-19 15:39:53 +00:00
.github .github: don't render author-facing text in ISSUE_TEMPLATE 2018-11-02 04:47:34 +00:00
api text/scanner: don't liberally consume (invalid) floats or underbars 2019-02-20 20:23:28 +00:00
doc doc: fix typo in go1.12 release notes 2019-04-16 14:47:58 +00:00
lib/time time: read 64-bit data if available 2019-02-26 23:10:35 +00:00
misc misc/cgo/testcshared: support testing on self-hosted android 2019-04-16 15:10:00 +00:00
src cmd/compile: move phi tighten after critical 2019-04-19 15:39:53 +00:00
test test: fix escape_runtime_atomic.go 2019-04-17 22:55:26 +00:00
.gitattributes
.gitignore .gitignore: ignore src/cmd/dist/dist 2017-10-28 21:55:49 +00:00
AUTHORS A+C: change email address for Elias Naur 2019-01-23 15:05:26 +00:00
CONTRIBUTING.md all: restore changes from faulty merge/revert 2018-02-12 20:13:59 +00:00
CONTRIBUTORS CONTRIBUTORS: second round of updates for Go 1.12 2019-01-30 18:01:19 +00:00
favicon.ico website: recreate 16px and 32px favicon 2016-08-25 15:43:32 +00:00
LICENSE
PATENTS
README.md README: linkify some paths 2018-06-06 18:07:01 +00:00
robots.txt

The Go Programming Language

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

Gopher image Gopher image by Renee French, licensed under Creative Commons 3.0 Attributions license.

Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.

Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.

Download and Install

Binary Distributions

Official binary distributions are available at https://golang.org/dl/.

After downloading a binary release, visit https://golang.org/doc/install or load doc/install.html in your web browser for installation instructions.

Install From Source

If a binary distribution is not available for your combination of operating system and architecture, visit https://golang.org/doc/install/source or load doc/install-source.html in your web browser for source installation instructions.

Contributing

Go is the work of thousands of contributors. We appreciate your help!

To contribute, please read the contribution guidelines: https://golang.org/doc/contribute.html

Note that the Go project uses the issue tracker for bug reports and proposals only. See https://golang.org/wiki/Questions for a list of places to ask questions about the Go language.