Skip to content

[#300] Reapply optimizer stages until fixpoint

Nikolay Yakimov requested to merge lierdakil/#300-optimizer-fixpoint into master

Description

Problem: optimizer doesn't revisit nodes, hence while there might be new optimization opportunities lower in the AST uncovered by optimizations higher in the AST, optimizer won't see those.

Solution: A bit ad-hoc, but at least it's simple. Reapply each optimizer stage until the output stops changing, up to a maximum number of iterations (to avoid going into infinite loops with contradictory rules; our default rules apparently aren't, but since we allow extending the ruleset, it seems like a good idea to do this)

Problem: Meta and WithLoc wrappers preclude some optimizations and those aren't meaningful for the optimized contract anyway.

Solution: Drop these wrappers during optimization.

Related issue(s)

Resolves #300 (closed)

Checklist for your Merge Request

Related changes (conditional)

  • Tests (see short guidelines)

    • If I added new functionality, I added tests covering it.
    • If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
  • Documentation

    • I checked whether I should update the docs and did so if necessary:
    • I updated changelog files of all affected packages released to Hackage if my changes are externally visible.

Stylistic guide (mandatory)

Edited by Nikolay Yakimov

Merge request reports