/ go Public
cmd/compile: bounds check not eliminated #45078
Issues related to the Go compiler and/or runtime.
The path to resolution is known, but the work has not been done.
I am writing code to count how long a common prefix two slices have, and I can't seem to make it bounds-check-free.
At current master, this function does not eliminate the bounds check for y[j], although it does for x[i]:
If I remove the
i < len(x) &&and the
i++, then the y[j] bounds check is eliminated:
If I leave out the
i++but bring back the (unnecessary)
i < len(x), the y[j] bounds check returns:
This is a simpler case that also has a bounds check and may share the same root cause:
This equivalent program has no check:
This suggests the problem has to do with either the inverted condition or the use of a short-circuit to exit the loop, neither of which should fundamentally change what is being proved.
The same happens counting backward: h0 and h1 have checks (h0 has just one), but h2 is check-free:
/cc @aclements @randall77 @rasky @brtzsnr (prove authors as best I can tell from git blame)
The text was updated successfully, but these errors were encountered: