-
-
Notifications
You must be signed in to change notification settings - Fork 883
Open
Description
Summary
The Venom optimizer could eliminate redundant condition checks when control flow guarantees the condition is true.
Example
In selector dispatch (dense jumptable), we have:
entry:
if calldatasize < 4: jump fallback
... dispatch logic ...
bucket_N:
if calldatasize > 3 AND selector_match: jump handler
The calldatasize > 3 check in bucket_N is redundant - if we reached that block, we already passed the calldatasize >= 4 check at entry.
Potential Approaches
- Range/interval analysis - track value ranges through control flow
- Dominated conditions tracking - if block B is dominated by a branch on condition C, C is known true/false in B
- Path-sensitive value numbering - extend SCCP with path conditions
Notes
- SCCP can't handle this (it's about path conditions, not constant values)
- This is a general optimization that would benefit any code with guarded branches
- Low priority but would improve bytecode size/gas for contracts with many external functions
🤖 Generated with Claude Code
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels