Avoid a redundant MOVE on some string interpolation setups#2324
Open
9382 wants to merge 4 commits intoluau-lang:masterfrom
Open
Avoid a redundant MOVE on some string interpolation setups#23249382 wants to merge 4 commits intoluau-lang:masterfrom
9382 wants to merge 4 commits intoluau-lang:masterfrom
Conversation
This keeps the generated bytecode of string interpolation in line with the result of writing the interpolation manually (e.g. `("%*"):format(xyz)`)
Also means string interpolation may sometimes be faster and use less bytecode, though the improvement is minimal in practice
tommyscholly
requested changes
Apr 6, 2026
Contributor
tommyscholly
left a comment
There was a problem hiding this comment.
This looks good, great catch on the redundant move. Just need the changes to be flagged.
Author
|
(Merged with master to resolve a conflict in Compiler, hopefully it isn't too much of a mess git-wise) |
SPY
reviewed
Apr 7, 2026
vegorov-rbx
approved these changes
Apr 9, 2026
tommyscholly
approved these changes
Apr 9, 2026
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 fixes a discrepancy between string interpolation (
local a = `{xyz}`) and the manually written equivilant version (local a = ("%*"):format(xyz)), where string interpolation would sometimes introduce aMOVEeven when it didn't need to as the target register was marked as temporaryBytecode difference
Code:
local f = `{global}`Before:
After:
This is also technically a performance improvement, though the difference is mostly unnoticeable in normal contexts (I'm seeing a 4-5% improvement on a 1e7 loop which is nothing but the optimisable string interp, so about as good as the case gets)
I've not written a new test case as
InterpStringRegisterCleanupalready covers the unoptimisable case