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

Comments

Projects
None yet
3 participants
@josharian
Contributor

josharian commented May 13, 2017

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

This comment has been minimized.

Contributor

randall77 commented May 15, 2017

Do you have an example where this happens?

@josharian

This comment has been minimized.

Contributor

josharian commented May 16, 2017

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

This comment has been minimized.

Contributor

josharian commented Mar 2, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment