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: prove doesn't know that integer extensions preserve bounds #26292

mvdan opened this Issue Jul 9, 2018 · 1 comment


None yet
5 participants
Copy link

commented Jul 9, 2018

As discovered by @aclements on

It's proving the second of two bounds-checks on that line, possibly because it's redundant with the first. I think it's not getting the first BCE because there's a ZeroExt8to64, and prove doesn't know that preserves the bounds of the original value:

v33 is b; v39 is const 128:

b8: ← b6
v38 (+889) = ZeroExt8to64 v33
v40 (889) = IsInBounds v38 v39
If v40 → b13 b14 (likely) (line 889)

Prove knows that v33 < 128, but that fact doesn't flow through to v38.

So, another way to fix this is to change "b < utf8.RuneSelf" to "int(b) < utf8.RuneSelf". At least for (*encodeState).string and (*encodeState).stringBytes, the only effect of this appears to be eliminating that one bounds check (and some register renaming).

(particular comment:


This comment has been minimized.

Copy link

commented Jul 9, 2018

Change mentions this issue: cmd/compile: handle sign/zero extension in prove

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.