Try it Live
Run Bytecode examples in the interactive playground
What are Fusions?
Fusions are sequences of 2-4 EVM instructions that:- Occur frequently in compiler output (Solidity, Vyper, etc.)
- Can be optimized by combining into single operations
- Enable static analysis (e.g., PUSH+JUMP = static jump target)
- Reveal semantics (e.g., function dispatch, callvalue checks)
Example
- Optimized to single “add immediate” operation
- Recognized as constant addition pattern
- Analyzed for gas savings
Fusion Categories
1. Arithmetic Fusions
Immediate arithmetic operations:
Example:
2. Bitwise Fusions
Immediate bitwise operations:
Common use: Masking (e.g.,
PUSH 0xFF, AND = mask to byte)
3. Memory Fusions
Immediate memory access:
Example:
4. Control Flow Fusions
Static control flow:
Example:
5. Stack Manipulation Fusions
Complex stack patterns:
These patterns appear in:
- ABI encoding/decoding
- Struct field access
- Array element computation
- Memory copying
6. Multi-Instruction Fusions
Sequences of same instruction:
Example:
7. Solidity-Specific Patterns
High-level language patterns:FUNCTION_DISPATCH
Extracts function selectors from Solidity function dispatcher:- ABI reconstruction from bytecode alone
- Function boundary detection for decompilation
- Selector collision detection
- Gas profiling per function
CALLVALUE_CHECK
Detects non-payable function checks:payable modifier.
Detection API
- TypeScript
Fusion detection integrates with iteration:
Options
Selective Detection
Usage Patterns
Fusion Statistics
Optimization Opportunities
Control Flow Graph from Fusions
Function Extraction
Pattern Frequency Analysis
Integration with Other APIs
With prettyPrint
Pretty print annotates fusions with ⚡ symbol:With analyzeBlocks
Detect fusions within blocks:With analyzeGas
Estimate gas savings from fusion optimization:Advanced Patterns
Custom Fusion Detection
Implement custom pattern matching:Fusion-Based Decompilation
Use fusions to identify high-level constructs:Compiler Fingerprinting
Different compilers generate different fusion patterns:Performance
Detection Overhead
Fusion detection adds minimal overhead:- Disabled: ~0.5ms per 1KB bytecode
- Enabled: ~0.8ms per 1KB bytecode
- Overhead: ~60% (still sub-millisecond for most contracts)
Caching
Fusion analysis is deterministic - results can be cached:Limitations
What’s Detected
✅ Sequential instruction patterns (2-4 instructions) ✅ Immediate values in PUSH instructions ✅ Static jump targets ✅ Function selectors (4-byte constants) ✅ Common compiler idiomsWhat’s Not Detected
❌ Semantically equivalent but structurally different patterns ❌ Patterns spanning multiple basic blocks ❌ Data-dependent patterns ❌ Runtime-computed patternsUse Cases
1. Bytecode Optimization
Identify patterns for optimization passes:2. Security Analysis
Detect suspicious patterns:3. Reverse Engineering
Reconstruct contract structure:See Also
- Instruction Types - OpcodeData union with all fusion types
- scan - Iterator with fusion detection
- Synthetic Opcodes - Extended opcode set
- analyzeBlocks - Basic block analysis
- prettyPrint - Visual fusion annotations

