Emit rem.un for unsigned modulo expressions#522
Merged
Conversation
Agent-Logs-Url: https://github.com/dadhi/FastExpressionCompiler/sessions/186dbd9c-2730-47f1-b5c7-fb8800c10d05 Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix CompileFast() to emit unsigned modulo for uint variables
Emit Apr 20, 2026
rem.un for unsigned modulo expressions
dadhi
approved these changes
Apr 21, 2026
|
@dadhi Wow thanks for the quick fix! Do you think it would be possible to do a release with the fix? |
Owner
|
Sure. Soon. |
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.
CompileFast()was emitting signed remainder IL forExpression.Moduloin unsigned scenarios, which breaks results when auintoperand has its high bit set. The regression showed up with block-localuintvariables, where the standard compiler/interpreter still produced the correct unsigned remainder.Codegen
ExpressionType.ModuloOpCodes.Rem_Unwhen the expression result type is an unsigned primitiveRegression coverage
uint0x80000000u % 3uto exercise the signed/unsigned distinctionScenario covered
This path should produce
2uand emitrem.un, notrem.