Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

feat(acvm)!: Simplification pass for ACIR #151

Merged
merged 10 commits into from
May 8, 2023
Merged

feat(acvm)!: Simplification pass for ACIR #151

merged 10 commits into from
May 8, 2023

Conversation

guipublic
Copy link
Contributor

Related issue(s)

Related to the noir issue 573

Description

Summary of changes

This PR adds a simplification pass for ACIR which indicates redundant opcodes
The simplification pass is not run automatically and must be called explicitly.
The simplification is applied during the fallback transformation, avoiding to re-process all the opcodes inside another pass.

Dependency additions / changes

Compiling ACIR requires now to pass a simplifier, which will apply the simplification. If one does not wish do to any simplification, he can simply provides the default simplifier.

Test additions / changes

Unit test is added

Checklist

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt with default settings.
  • I have linked this PR to the issue(s) that it resolves.
  • I have reviewed the changes on GitHub, line by line.
  • I have ensured all changes are covered in the description.

Copy link
Member

@TomAFrench TomAFrench left a comment

Choose a reason for hiding this comment

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

I think we should explore pulling the usage of the simplifier out of acvm::compiler::compile.

In the context of noir-lang/noir#1102, ideally we'd perform all the generic optimisations separately to the backend-specific optimisations. We can then have our generic ACIR artifacts be optimised and then have acvm::compiler::compile just tailor them to the backend.

@TomAFrench TomAFrench linked an issue Apr 7, 2023 that may be closed by this pull request
@phated phated changed the title feat!(acvm): Simplification pass for ACIR feat(acvm)!: Simplification pass for ACIR Apr 14, 2023
@guipublic
Copy link
Contributor Author

I think we should explore pulling the usage of the simplifier out of acvm::compiler::compile.

I moved it to the optimizers module

Copy link
Contributor

@kevaundray kevaundray left a comment

Choose a reason for hiding this comment

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

I'm okay with this PR -- I think there are things that ideally get cleaned up but since its an optional pass and I predict that we can do this in an ssa optimization pass after legalization, we may be able to remove the need for it and other optimization passes in the future.

Note:

  • We should use a separate PR to modify quotient directive (breaking change); its bad practice because it introduces feature creep and it is not indicative from the PR title. One may naively assume that this change is needed for the simplification pass.
  • I'd prefer that we put the simplification pass inside of the compile method so its not a special pass that now needs to be initialized.

@guipublic guipublic added this pull request to the merge queue May 8, 2023
Merged via the queue into master with commit 7bc42c6 May 8, 2023
@github-actions github-actions bot mentioned this pull request May 8, 2023
@phated phated deleted the gd/simplify branch May 8, 2023 14:43
TomAFrench added a commit that referenced this pull request May 10, 2023
* master:
  chore(acvm)!: Backend trait must implement Debug (#275)
  chore!: remove `OpcodeResolutionError::UnexpectedOpcode` (#274)
  chore(acvm)!: rename `hash_to_field128_security` to `hash_to_field_128_security` (#271)
  feat(acvm)!: update black box solver interfaces to match `pwg:black_box::solve` (#268)
  chore(acir_field): remove unnecessary `to_vec()` (#267)
  chore(acvm)!: expose separate solvers for AND and XOR opcodes (#266)
  feat(acvm)!: Simplification pass for ACIR (#151)
TomAFrench added a commit that referenced this pull request May 16, 2023
* master: (49 commits)
  feat(acvm)!: Add CommonReferenceString backend trait (#231)
  fix(acir): Hide variants of WitnessMapError and export it from package (#283)
  feat!: Introduce WitnessMap data structure to avoid leaking internal structure (#252)
  feat!: use struct variants for blackbox function calls (#269)
  chore(acvm)!: Backend trait must implement Debug (#275)
  chore!: remove `OpcodeResolutionError::UnexpectedOpcode` (#274)
  chore(acvm)!: rename `hash_to_field128_security` to `hash_to_field_128_security` (#271)
  feat(acvm)!: update black box solver interfaces to match `pwg:black_box::solve` (#268)
  chore(acir_field): remove unnecessary `to_vec()` (#267)
  chore(acvm)!: expose separate solvers for AND and XOR opcodes (#266)
  feat(acvm)!: Simplification pass for ACIR (#151)
  changes the name of blake to be blakes2s256 (#261)
  update hash functions (#260)
  feat!: Remove `solve` from PWG trait & introduce separate solvers for each blackbox (#257)
  chore: Release 0.11.0 (#250)
  feat(acvm): Add generic error for failing to solve an opcode (#251)
  fix(acir): Fix `Expression` multiplication to correctly handle degree 1 terms (#255)
  chore(acir): organise opcodes definitions (#254)
  chore: remove usage of `insert_witness` with `insert_value` (#253)
  feat: Add Keccak Hash function (#259)
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pass to replace all witness constants with constants
3 participants