Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Implement constant folding during the mem2reg pass #2464

Merged
merged 20 commits into from
Aug 30, 2023

Conversation

jfecher
Copy link
Contributor

@jfecher jfecher commented Aug 28, 2023

Description

Problem*

Resolves #2445

Summary*

This is the second PR of mem2reg updates and requires the array aliasing PR to work.

This PR changes mem2reg to also perform constant folding while doing the pass instead of calling set_value_from_id. The reasoning for this is given in #2445 but in short, you could run into situations before where after mem2reg, constant folding would find and stop at another reference, necessitating another mem2reg and constant folding pass, and so in. So if you had N mem2reg + constant folding passes you could always construct a program that required N + 1. Performing constant folding during mem2reg breaks this dependency as now an array_get instruction that can be simplified is simplified out immediately instead of remaining as an opaque alias to some unknown reference.

Documentation

  • This PR requires documentation updates when merged.

    • I will submit a noir-lang/docs PR.
    • I will request for and support Dev Rel's help in documenting this PR.

Additional Context

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@jfecher jfecher changed the title Jf/mem2reg constant folding fix: Implement constant folding during the mem2reg pass Aug 28, 2023
@jfecher
Copy link
Contributor Author

jfecher commented Aug 29, 2023

Also fixes #2221

Base automatically changed from jf/mem2reg-array-aliasing to master August 29, 2023 18:08
@jfecher jfecher linked an issue Aug 29, 2023 that may be closed by this pull request
Copy link
Contributor

@vezenovm vezenovm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM just a couple small comments

@jfecher jfecher added this pull request to the merge queue Aug 30, 2023
Merged via the queue into master with commit 5361ebd Aug 30, 2023
16 checks passed
@jfecher jfecher deleted the jf/mem2reg-constant-folding branch August 30, 2023 00:48
TomAFrench added a commit that referenced this pull request Aug 30, 2023
* master:
  chore!: Remove keys from preprocessed artifacts (#2283)
  chore(noir): Release 0.10.5 (#2482)
  feat: Basic implementation of traits (#2368)
  fix: Implement constant folding during the mem2reg pass (#2464)
TomAFrench added a commit that referenced this pull request Aug 31, 2023
* master:
  chore: update ACIR artifacts (#2503)
  chore!: Update to `acvm-backend-barretenberg` v0.12.0 (#2377)
  fix: Bring back accidentally deleted double_verify_proof test. (#2501)
  chore(aztec_noir): import aztec library if not found yet (#2492)
  chore(abi)!: Replace struct name with fully qualified struct path (#2374)
  chore!: Remove keys from preprocessed artifacts (#2283)
  chore(noir): Release 0.10.5 (#2482)
  feat: Basic implementation of traits (#2368)
  fix: Implement constant folding during the mem2reg pass (#2464)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Constant fold during mem2reg pass
2 participants