Fix eel2 regNN*regNN optimizer bug#34
Open
shanevbg wants to merge 1 commit into
Open
Conversation
nseel_resolve_named_symbol clears sname[0] for regNN variables (line 983), which makes the x*x → sqr(x) optimizer treat ALL regNN vars as identical (it compares relname strings, which are now all empty). This causes expressions like `reg10*reg20` to be compiled as `sqr(reg10)`. Two fixes: 1. Remove `sname[0]=0` — the comment already says "this shouldn't be needed anyway", and it breaks the optimizer's string comparison. 2. Add valuePtr comparison as primary check in the VARPTR case of the sqr() optimization, consistent with the existing VARPTRPTR case (line 2464). Also guard the string fallback with relname[0] check to prevent empty-string false matches. Discovered in MilkDrop preset rendering where rotation matrices using different regNN variables produced incorrect results (squaring one operand instead of multiplying two distinct registers).
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.
Summary
nseel_resolve_named_symbolclearssname[0]=0forregNNvariables (line 983), which causes thex*x → sqr(x)optimizer to treat ALLregNNvariables as identical (comparing empty strings).reg10*reg20gets compiled assqr(reg10).sname[0]=0— the comment already says "this shouldn't be needed anyway"valuePtrcomparison as primary check in theVARPTRcase of the sqr() optimization, consistent with the existingVARPTRPTRcase. Guard the string fallback withrelname[0]check.Reproduction
Any EEL script multiplying two different
regNNvariables produces incorrect results:Discovered in MilkDrop/Milkwave preset rendering where rotation matrices using different regNN variables produced incorrect visual output.
Changes
WDL/eel2/nseel-compiler.c— 2 insertions, 2 deletions:sname[0]=0that cleared the variable name after resolving regNN globalsvaluePtrpointer comparison (like VARPTRPTR case), guard string comparison withrelname[0]check