-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: possible prove pass bug #67625
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
Comments
I think the missing piece is that the rule that says |
Hum, I wasn't aware it could backprop inferences like this, I thought this would only be applied during DFS. |
Yes, I think the right fix is to apply/remove it during DFS, at the point of the modulo (or maybe the block after? I'm not sure). I plan on revamping much of this pass for 1.24, so if there isn't a demonstrable bug, it can just wait and may become obsolete. |
This should be fixed with the new prove pass implementation. |
This doesn't actually compile to incorrect code yet, but it gets close.
The crux of the problem is that we have the rule that, given
r := a%b
, we can deriver < b
(in the unsigned domain). Which at first looks reasonable. But reading it "backwards" causes trouble:r < b
=>b > r
=>b > 0
=>b != 0
. But that's the loop condition, implying that we don't actually need to do the loop test.The implication above can only really be relied upon after the modulo operation runs (and thus panics, if
b==0
). Fortunately for us that's how the current compiler happens to use this information. But it isn't scoped to "after" in the current prove pass, so it is something of a ticking time bomb.Filing for my own use for later. I'm rewriting some of this code.
The text was updated successfully, but these errors were encountered: