feat[venom]: fold var-vs-var comparisons and tighten range-based evaluator folding#4827
Open
harkal wants to merge 10 commits intovyperlang:masterfrom
Open
feat[venom]: fold var-vs-var comparisons and tighten range-based evaluator folding#4827harkal wants to merge 10 commits intovyperlang:masterfrom
harkal wants to merge 10 commits intovyperlang:masterfrom
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4827 +/- ##
==========================================
- Coverage 92.93% 92.88% -0.05%
==========================================
Files 157 157
Lines 21943 22039 +96
Branches 3927 3965 +38
==========================================
+ Hits 20392 20472 +80
- Misses 1026 1032 +6
- Partials 525 535 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Fix _range_spans_sign_boundary to detect ranges that extend from non-negative into high unsigned territory (lo >= 0 and hi > MAX_INT256) - Add symmetric lo bound check for signed comparisons (lo >= MIN_INT256) - Add tests for boundary spanning cases and negative-vs-nonnegative unsigned comparisons
Range evaluators like _eval_mod, _eval_div, _eval_shr, etc. previously only worked when the divisor/shift amount was a direct IRLiteral. This meant that patterns like: %div = 10 %result = mod %x, %div would produce TOP ranges instead of [0, 9]. Now evaluators first try to get a literal value, and if that fails, check if the operand has a constant range that can be used instead. This enables more cases where var-to-var comparison folding can trigger. Updated test_eval_byte.py to reflect improved constant propagation.
📊 Bytecode Size Changes (venom)No changes detected. Full bytecode sizes
|
Collaborator
Author
|
Review session |
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.
What I did
I extended Venom algebraic optimization to fold comparisons when both operands are variables, not just literals.
lt,gt,slt, andsgtusing variable range analysis.byte,signextend,mod,div,shl,shr,sar,sdiv, andsmod.disjoint ranges, overlapping ranges (no-fold cases), boundary-touching cases,
signed wraparound edge cases, unsigned negative-vs-nonnegative behavior,
and assert elimination after comparison folding.
byteevaluator tests to reflect constant-range variable index folding.How I did it
How to verify it
Commit message
Description for the changelog
Cute Animal Picture