-
-
Notifications
You must be signed in to change notification settings - Fork 606
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
(Bug 3147) Reimplemented Value-Range Propagation. #116
Conversation
This should have fixed Bug 3147. The changes are: - VRP is applied on all integer arithmetic operators, i.e. + - * / % << >> >>> & | ^, and the unary ~ -. - Range with signed numbers is properly supported by using a 65-bit number internally. - The algorithm for & | ^ are rewritten to produce a much tighter range than before. - Several unlisted bugs producing a wrong range regarding << >> >>> are fixed
Awesome! |
There was this large discussion about VRP for & and |. Some people came up with pretty compelling algorithms - did you follow that? If not, you may want to compare notes. |
One more thing - is VRP effective in switch statements? Consider: int x; With VRP in tow, the compiler should figure that only cases 0 through 7 are needed. |
@andralex: Thanks for reminding. I've checked Adam's algorithm, and his provides a tighter upper bound, but a looser lower bound. So I have combined the two. This should be able to provide a tightest bound in eighty-something percent of all possible cases for As for int x;
final switch (x & 0xf0) {
...
} will require every (241) case in (0, 1, 2, ..., 0xf0) be present, although only 16 cases (0, 0x10, ..., 0xf0) are needed. |
@kennytm: Thanks, that's great. The exhaustive checker has its role and merits, but I'd generally hope for bounds that are provably the tightest. (Then the exhaustive checker would serve as a debugger.) Absent the theoretical proof, of course this pull is much better than what we have. Regarding switch - good point. I think a common pattern is to use switch with a small power-of-two-minus-one mask, so we should make sure we get that covered. |
I'll leave it to Walter and Don to pull this. |
Halp! This can't be auto-merged, what do I do? People didn't like when I did it manually :-( |
Do what Linus does, and tell the submitter to do the honors instead! |
If Linus says so, it must be ok! |
Conflicts: src/freebsd.mak src/linux.mak src/openbsd.mak src/osx.mak src/solaris.mak
@WalterBright: done :) |
awesome! |
(Bug 3147) Reimplemented Value-Range Propagation.
Fixed issue 6193: Appender.clear() functionality or documentation
This should have fixed bug 3147 (and bug 6000, bug 5225). The changes are:
+
-
*
/
%
<<
>>
>>>
&
|
^
, and the unary~
-
.&
|
^
are rewritten to produce a much tighter range than before.<<
>>
>>>
are fixed.