-
-
Notifications
You must be signed in to change notification settings - Fork 668
Issue 13976 - Value range propagation to disable some slice bound tests #4293
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
Conversation
|
Ping: @WalterBright and @yebblies . |
src/expression.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add comment indicating what these two fields mean, i.e. lowerLessThan means less than what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, renamed two fields, and added explanation comments.
Issue 13976 - Value range propagation to disable some slice bound tests
|
Thanks Kenji!! |
|
Does this include avoiding range checking in expressions such as x[0 .. $/2, $/2 .. $]which is a reoccurring pattern in D-style binary divide-and-conquer algorithms. It would be super-cool if it worked for rational variants with slice indexes in the form $*p/qwhere it can be statically proven that |
|
@nordlow : all existing range checking only involves constants. There is no mechanism for ranges relative to variables, for example array lengths. Of course that would be awesome but it would be a massive new feature. |
|
I take it that means lots of changes in lots of files in DMD, right? |
|
Well, it's a new algorithm, really. At the moment a value range is just two integers, lo and hi. Once you allow variables, it becomes an equation... So I dunno how extensive the changes would be. |
|
Is the usage of |
|
Yeah. Though if you just wanted to do the $ case you mentioned, in SliceExp::optimize(), after each optimize(WANTvalue) you could replace each getIntRange call with a check for TOKmul, if it is TOKdivl(VarExp(__dollar), xxx) and xxx > 1 it is in range. You'd need to check all the cases though, it will get a bit messy. |
|
Ok. Great. I guess I can set Is this sufficient in order to trigger avoidance of range-checking further in the pipeline? However, I'm missing |
The variable you're looking for is |
|
How can |
Array indices are unsigned. |
|
Ahh, I get it. Thanks. |
|
Continued discussion at #4351 |
Extends dlang#4293, and inspired by dlang#4351.
Extends dlang#4293, and inspired by dlang#4351.
https://issues.dlang.org/show_bug.cgi?id=13976
Example:
With 2.066:
With this PR:
The boundary check and
__arraycall are completely removed.