[SYSTEMDS-2801] Rewrite rule to remove (par)for-loops over empty sequences.#1165
Closed
pdamme wants to merge 1 commit intoapache:masterfrom
Closed
[SYSTEMDS-2801] Rewrite rule to remove (par)for-loops over empty sequences.#1165pdamme wants to merge 1 commit intoapache:masterfrom
pdamme wants to merge 1 commit intoapache:masterfrom
Conversation
…ence. This commit adds a new StatementBlockRewriteRule removing (par)for-loops which are known to iterate over an empty sequence, and, thus, will not perform a single iteration. This works if the loop's from, to, and increment are constants (possibly DML script arguments, and after constant folding). Furthermore, OptimizerUtils has a new flag determining whether this rule shall be applied. In ProgramRewriter's default rule sequence, this new rule is inserted directly after the removal of unnecessary branches, since they have a lot in common. Merging subsequent blocks is done once afterwards if any of removing unnecessary branches or removing (par)for-loops shall be applied.
Contributor
|
Thanks for adding this rewrite. |
Contributor
Author
|
Good idea. I will add a test case soon. |
Contributor
|
LGTM - welcome to SystemDS @pdamme and thanks for the patch. During the merge, I fixed a few related for/parfor issues (for correctly handling special values like NaN/Inf/-Inf), fixed the issue of my previous commit, simplified and generalized the rewrite a bit, and added the tests you already discussed. The test simply checks that after this rewrite, we do common subexpression elimination of ops before and after the loop. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit adds a new StatementBlockRewriteRule removing (par)for-loops which are known to iterate over an empty sequence, and, thus, will not perform a single iteration. This works if the loop's from, to, and increment are constants (possibly DML script arguments, and after constant folding). Furthermore, OptimizerUtils has a new flag determining whether this rule shall be applied. In ProgramRewriter's default rule sequence, this new rule is inserted directly after the removal of unnecessary branches, since they have a lot in common. Merging subsequent blocks is done once afterwards if any of removing unnecessary branches or removing
(par)for-loops shall be applied.