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: some missing BCE cases #40987

Open
go101 opened this issue Aug 23, 2020 · 3 comments
Open

cmd/compile: some missing BCE cases #40987

go101 opened this issue Aug 23, 2020 · 3 comments

Comments

@go101
Copy link

@go101 go101 commented Aug 23, 2020

What version of Go are you using (go version)?

$ go version
go version go1.15 linux/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

package foo

func f(a []int) {
	//a = a[:256] // works
	_ = a[255] // doesn't work
	for i := 0; i < 50000; i++ {
	    _ = a[byte(i)] // BCEed?
	}
}

func g(a []int) {
	//a = a[:4096] // works
	_ = a[4095] // doesn't work
	for i := 0; i < 50000; i++ {
	    _ = a[i&4095] // BCEed?
	}
}

What did you expect to see?

Both tricks work.

What did you see instead?

One of them doesn't work.

@go101
Copy link
Author

@go101 go101 commented Aug 23, 2020

And this:

package foo

func f1(a []int) (r int) {
	n := len(a)
	for i := 0; i < n - 3; i += 4 {
		r += a[i] // BCEed 
	}
	return r
}

func f2(a []int) (r int) {
	n := len(a)
	for i := 0; i <= n - 4; i += 4 {
		r += a[i] // not BCEed
	}
	return r
}

I rememberd that before it behaved the inverse.

@randall77
Copy link
Contributor

@randall77 randall77 commented Aug 23, 2020

@randall77 randall77 added this to the Unplanned milestone Aug 23, 2020
@mvdan
Copy link
Member

@mvdan mvdan commented Aug 24, 2020

And @zdjones

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.