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: fix bounds check regressions from Go 1.6 #14721

Closed
rsc opened this issue Mar 8, 2016 · 4 comments
Closed

cmd/compile: fix bounds check regressions from Go 1.6 #14721

rsc opened this issue Mar 8, 2016 · 4 comments

Comments

@rsc
Copy link
Contributor

rsc commented Mar 8, 2016

The old compiler knows that

var x [16]byte
z := x[i&15]
z := x[i%16]
...

does not need bounds checks. We need to make sure that the new SSA compiler knows this too. Today it seems not to, in certain cases.

Per discussion today.

@rsc rsc added this to the Go1.7Early milestone Mar 8, 2016
@randall77
Copy link
Contributor

Note that [i%16] can only skip the bounds check if i is unsigned (or can otherwise be proved >= 0).

@brtzsnr
Copy link
Contributor

brtzsnr commented Mar 8, 2016

The first one can be done with rewrites easily. Something like.

(IsInBounds (And64 (Const64 [c]) x) (Const64 [d])) && c < d -> (ConstBool [1]).

Is something more general than this you have in mind?

@rsc
Copy link
Contributor Author

rsc commented Mar 8, 2016 via email

@gopherbot
Copy link

CL https://golang.org/cl/20482 mentions this issue.

@golang golang locked and limited conversation to collaborators Mar 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants