@@ -281,50 +281,85 @@ The following transformation steps are the main components:
281
281
- Redundant Assign Eliminator
282
282
- Full Inliner
283
283
284
+ .. _optimizer-steps :
285
+
284
286
Optimizer Steps
285
287
---------------
286
288
287
289
This is a list of all steps the Yul-based optimizer sorted alphabetically. You can find more information
288
290
on the individual steps and their sequence below.
289
291
290
- - :ref: `block-flattener `.
291
- - :ref: `circular-reference-pruner `.
292
- - :ref: `common-subexpression-eliminator `.
293
- - :ref: `conditional-simplifier `.
294
- - :ref: `conditional-unsimplifier `.
295
- - :ref: `control-flow-simplifier `.
296
- - :ref: `dead-code-eliminator `.
297
- - :ref: `equal-store-eliminator `.
298
- - :ref: `equivalent-function-combiner `.
299
- - :ref: `expression-joiner `.
300
- - :ref: `expression-simplifier `.
301
- - :ref: `expression-splitter `.
302
- - :ref: `for-loop-condition-into-body `.
303
- - :ref: `for-loop-condition-out-of-body `.
304
- - :ref: `for-loop-init-rewriter `.
305
- - :ref: `expression-inliner `.
306
- - :ref: `full-inliner `.
307
- - :ref: `function-grouper `.
308
- - :ref: `function-hoister `.
309
- - :ref: `function-specializer `.
310
- - :ref: `literal-rematerialiser `.
311
- - :ref: `load-resolver `.
312
- - :ref: `loop-invariant-code-motion `.
313
- - :ref: `redundant-assign-eliminator `.
314
- - :ref: `reasoning-based-simplifier `.
315
- - :ref: `rematerialiser `.
316
- - :ref: `SSA-reverser `.
317
- - :ref: `SSA-transform `.
318
- - :ref: `structural-simplifier `.
319
- - :ref: `unused-function-parameter-pruner `.
320
- - :ref: `unused-pruner `.
321
- - :ref: `var-decl-initializer `.
292
+ ============ ===============================
293
+ Abbreviation Full name
294
+ ============ ===============================
295
+ ``f `` :ref: `block-flattener `
296
+ ``l `` :ref: `circular-reference-pruner `
297
+ ``c `` :ref: `common-subexpression-eliminator `
298
+ ``C `` :ref: `conditional-simplifier `
299
+ ``U `` :ref: `conditional-unsimplifier `
300
+ ``n `` :ref: `control-flow-simplifier `
301
+ ``D `` :ref: `dead-code-eliminator `
302
+ ``E `` :ref: `equal-store-eliminator `
303
+ ``v `` :ref: `equivalent-function-combiner `
304
+ ``e `` :ref: `expression-inliner `
305
+ ``j `` :ref: `expression-joiner `
306
+ ``s `` :ref: `expression-simplifier `
307
+ ``x `` :ref: `expression-splitter `
308
+ ``I `` :ref: `for-loop-condition-into-body `
309
+ ``O `` :ref: `for-loop-condition-out-of-body `
310
+ ``o `` :ref: `for-loop-init-rewriter `
311
+ ``i `` :ref: `full-inliner `
312
+ ``g `` :ref: `function-grouper `
313
+ ``h `` :ref: `function-hoister `
314
+ ``F `` :ref: `function-specializer `
315
+ ``T `` :ref: `literal-rematerialiser `
316
+ ``L `` :ref: `load-resolver `
317
+ ``M `` :ref: `loop-invariant-code-motion `
318
+ ``r `` :ref: `redundant-assign-eliminator `
319
+ ``R `` :ref: `reasoning-based-simplifier ` - highly experimental
320
+ ``m `` :ref: `rematerialiser `
321
+ ``V `` :ref: `SSA-reverser `
322
+ ``a `` :ref: `SSA-transform `
323
+ ``t `` :ref: `structural-simplifier `
324
+ ``p `` :ref: `unused-function-parameter-pruner `
325
+ ``u `` :ref: `unused-pruner `
326
+ ``d `` :ref: `var-decl-initializer `
327
+ ============ ===============================
328
+
329
+ Some steps depend on properties ensured by ``BlockFlattener ``, ``FunctionGrouper ``, ``ForLoopInitRewriter ``.
330
+ For this reason the Yul optimizer always applies them before applying any steps supplied by the user.
331
+
332
+ The ReasoningBasedSimplifier is an optimizer step that is currently not enabled
333
+ in the default set of steps. It uses an SMT solver to simplify arithmetic expressions
334
+ and boolean conditions. It has not received thorough testing or validation yet and can produce
335
+ non-reproducible results, so please use with care!
322
336
323
337
Selecting Optimizations
324
338
-----------------------
325
339
326
- Detailed information regrading the optimization sequence as well a list of abbreviations is
327
- available in the :ref: `Yul optimizer docs <optimization-step-sequence >`.
340
+ By default the optimizer applies its predefined sequence of optimization steps to the generated assembly.
341
+ You can override this sequence and supply your own using the ``--yul-optimizations `` option:
342
+
343
+ .. code-block :: bash
344
+
345
+ solc --optimize --ir-optimized --yul-optimizations ' dhfoD[xarrscLMcCTU]uljmul:fDnTOc'
346
+
347
+ The order of steps is significant and affects the quality of the output.
348
+ Moreover, applying a step may uncover new optimization opportunities for others that were already applied,
349
+ so repeating steps is often beneficial.
350
+
351
+ The sequence inside ``[...] `` will be applied multiple times in a loop until the Yul code
352
+ remains unchanged or until the maximum number of rounds (currently 12) has been reached.
353
+ Brackets (``[] ``) may be used multiple times in a sequence, but can not be nested.
354
+
355
+ An important thing to note, is that there are some hardcoded steps that are always run before and after the
356
+ user-supplied sequence, or the default sequence if one was not supplied by the user.
357
+
358
+ The cleanup sequence delimiter ``: `` is optional, and is used to supply a custom cleanup sequence
359
+ in order to replace the default one. If omitted, the optimizer will simply apply the default cleanup
360
+ sequence. In addition, the delimiter may be placed at the beginning of the user-supplied sequence,
361
+ which will result in the optimization sequence being empty, whereas conversely, if placed at the end of
362
+ the sequence, will be treated as an empty cleanup sequence.
328
363
329
364
Preprocessing
330
365
-------------
0 commit comments