Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: trim more blocks? #20354

Open
josharian opened this issue May 13, 2017 · 3 comments
Open

cmd/compile: trim more blocks? #20354

josharian opened this issue May 13, 2017 · 3 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Performance
Milestone

Comments

@josharian
Copy link
Contributor

In ssa/trim.go, func emptyBlock, the only op that counts as not generating instructions is OpPhi. But OpVarDef, OpVarKill, OpVarLive, and OpKeepAlive could probably qualify as "not generating instructions" as well. This would allow trimming more blocks.

cc @randall77

@josharian josharian added this to the Go1.10 milestone May 13, 2017
@randall77
Copy link
Contributor

Do you have an example where this happens?

@josharian
Copy link
Contributor Author

Sure. func pcvalue in package runtime:

b7: ← b8
v63 = VarKill <mem> {.autotmp_22} v30
Plain → b15

It looks like this is killing the temp copy of cache.entries on the way out of the cache checking loop.

Instrumenting the compiler shows 295 new trimmable blocks in make.bash.

func emptyBlock(b *Block) bool {
	if emptyBlock2(b) && !emptyBlock1(b) {
		fmt.Printf("%v in %v\n", b, b.Func.Name)
	}
	return emptyBlock1(b)
}

func emptyBlock1(b *Block) bool {
	for _, v := range b.Values {
		switch v.Op {
		case OpPhi:
			// not an actual instruction
		default:
			return false
		}
	}
	return true
}

func emptyBlock2(b *Block) bool {
	for _, v := range b.Values {
		switch v.Op {
		case OpPhi, OpVarDef, OpVarKill, OpVarLive, OpKeepAlive:
			// not an actual instruction
		default:
			return false
		}
	}
	return true
}

@bradfitz bradfitz modified the milestones: Go1.10, Go1.11 Nov 28, 2017
@josharian
Copy link
Contributor Author

The new “zero width” op flag might be helpful for making this more powerful: https://go-review.googlesource.com/#/c/97957/

@bradfitz bradfitz modified the milestones: Go1.11, Unplanned May 18, 2018
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Performance
Projects
None yet
Development

No branches or pull requests

4 participants