---
# System prepended metadata

title: Solidity Optimizer Overview

---

---
type: slide
---

# Solidity Optimizer Overview

@chriseth / February 2023

---

## Different Kinds of Optimizers

- Currently no optimization on Solidity AST basis
- Yul Optimizer (IR-level)
- EVMASM optimizer (opcode-level)

---

## EVMASM optimizer

- Entry point is ``Assembly::optimise``
- Inliner (uses size/cost tradeoff)
- Jumpdest Remover
- Peephole Optimizer
- Block Deduplicator
- CSE (does more thas just CSE)
- Constant Optimizer (uses size/cost tradeoff)

---

## Yul Optimizer

- Built from different easy to understand steps.
- Proper Yul code between each step.
- No "hidden" data structures or analysis information.
- If a job can be done by combining two simple steps, split it.

---

### Optimizer Step Details

- Each step has name and unique letter:
    - `static constexpr char const* name{"SSATransform"};`
    - `OptimiserSuite::stepNameToAbbreviationMap`
- Use `yulopti` tool to run individual steps on Yul code

---

### Some Important Steps

- Disambiguator
- CSE
- Conditional Simplifier
- DeadCodeEliminator
- ExpressionSplitter / ExpressionJoiner
- SSATransform
- LoadResolver
- NameSimplifier

---

### Some More Important Steps

- StackToMemoryMover
- UnusedAssignEliminator
- UnusedStoreEliminator
- UnusedPruner
- FullInliner
- ExpressionInliner