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: redundant branch #22025

Open
randall77 opened this issue Sep 25, 2017 · 0 comments
Labels
Milestone

Comments

@randall77
Copy link
Contributor

@randall77 randall77 commented Sep 25, 2017

func f(x interface{}) bool {
	if x == nil {
		return false
	}
	switch x.(type) {
	case bool:
		return true
	default:
		return false
	}
}

Compiles to

	0x0000 00000 (/Users/khr/go/tmp4.go:3)	MOVQ	"".x+8(SP), AX
	0x0005 00005 (/Users/khr/go/tmp4.go:4)	TESTQ	AX, AX
	0x0008 00008 (/Users/khr/go/tmp4.go:4)	JEQ	47
	0x000a 00010 (/Users/khr/go/tmp4.go:7)	JEQ	41
        ...

That second branch is useless. We should get rid of it somehow.

@randall77 randall77 added this to the Go1.10 milestone Sep 25, 2017
@bradfitz bradfitz modified the milestones: Go1.10, Go1.11 Nov 28, 2017
@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
Projects
None yet
2 participants
You can’t perform that action at this time.