scriptcomp: Optimize typical for loop construct instructions#86
Merged
mtijanic merged 2 commits intoniv:masterfrom Dec 25, 2023
Merged
scriptcomp: Optimize typical for loop construct instructions#86mtijanic merged 2 commits intoniv:masterfrom
mtijanic merged 2 commits intoniv:masterfrom
Conversation
1 task
niv
pushed a commit
that referenced
this pull request
Jan 28, 2025
This optimization appears to cause issues with increment/decrement ops, like infinite loops. Disabling it for now. Open issue: #141 Related PR: #86 ## Testing The script in the open issue mentioned above that hit the TMI limit due to an infinite loop now works correctly. ## Changelog ### Changed - scriptcomp: disabled a for loop optimization where the compiler would sometimes generate code that caused an infinite loop. ## Licence - [x] I am licencing my change under the project's MIT licence, including all changes to GPL-3.0 licenced parts of the codebase.
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.
The common loop pattern of
for (i = 0; i < 1000; ++i)gets compiled intoThe inc/dec operations can reach all across the stack and don't need to be copied over to top of stack. However, since
++ireturns a value we have to emit the RUNSTACK_COPY. But, when we don't use that value, we just immediately clear it with MODIFY_STACK_POINTER. Just don't do either.Testing
Added an extra test case with ++i and runtime check on iteration count.
Verified disassembly of
is sane.
Changelog
Performance Improvements
for (i = 0; i < N; ++i)Licence