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

feat: Execute brillig opcodes with constant inputs at compile-time #2190

Merged
merged 13 commits into from
Aug 11, 2023

Conversation

TomAFrench
Copy link
Member

@TomAFrench TomAFrench commented Aug 5, 2023

Description

Problem*

Resolves #2189

Summary*

This PR executes any Brillig opcodes for which all of the inputs are known at compile time so that we can just create constants for the results to inject where necessary. This allows us to completely solve some test circuits at compile time.

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.

@TomAFrench TomAFrench force-pushed the constant-brillig-execution branch 3 times, most recently from bdcf96b to f0656b0 Compare August 5, 2023 11:42
@TomAFrench TomAFrench changed the title feat: execute brillig opcodes with constant inputs at compile-time feat: Execute brillig opcodes with constant inputs at compile-time Aug 5, 2023
@TomAFrench TomAFrench marked this pull request as ready for review August 6, 2023 18:27
@TomAFrench TomAFrench marked this pull request as draft August 6, 2023 18:35
@TomAFrench TomAFrench marked this pull request as ready for review August 7, 2023 08:51
* master:
  chore: Improve unary error (#2199)
  chore: separate integration test cases into directories based on expected result (#2198)
  chore: remove stale comment (#2197)
@jfecher
Copy link
Contributor

jfecher commented Aug 7, 2023

Would this still be needed if we only translated the SSA -> Brillig after performing the SSA optimizations? I believe this is something we wanted to do anyway.

@TomAFrench
Copy link
Member Author

I'm not sure however it's pretty self contained so we could always remove it once that's implemented.

#2066

* master:
  chore: Remove symlink and dummy config file (#2200)
  fix: Fix an ICE when reassigning a mutable lambda variable to one with a different environment type (#2172)
  feat: Only create new witnesses for distinctiveness when duplicates exist (#2191)
  chore: Use helper functions for getting values of `AcirVar`s (#2194)
  feat: Add support for slices of structs and nested slices in brillig (#2084)
  feat: Perform sorting of constant arrays at compile time (#2195)
* master:
  feat: Optimize equality checks between a boolean and constant (#2201)
  feat: Issue warning for signed integers (#2185)
  chore: Add `noir_wasm` testing workflow (#1921)
* master:
  fix: Set location before cast instructions in SSA (#2202)
  fix: simplification of overflowing integer operations (#2153)
* master: (29 commits)
  feat(nargo): Add support for contracts in `nargo check` (#2267)
  chore(ci): Name wasm job more clearly (#2269)
  chore(ci): Create cache key with consideration to target (#2273)
  chore(ci): Run publish workflow against PRs (#2268)
  chore: Merge in contents of `build-nargo` repository (#2211)
  fix(lsp): Improve dependency resolution in context of `Nargo.toml` (#2226)
  chore: Remove unnecessary duplication in how we test Noir compiler (#2248)
  fix: properly capture lvalues in closure environments (#2120) (#2257)
  fix: Optimize contracts built by `nargo info` (#2259)
  chore: impl Display for DebugType (#2258)
  chore: update `noir_wasm` build process to match `acvm_js` (#2067)
  feat: Implement traits - parser support #2094 (#2230)
  chore: Refactor DefCollector duplicate errors (#2231)
  chore: Address clippy warnings (#2246)
  feat: Support `contract` package type in `nargo info` command (#2249)
  feat: Add slice append (#2241)
  chore: Bump `async-lsp` to v0.0.5 (#2186)
  chore: Move the remaining `nargo_cli` lib funcs into `nargo` crate (#2225)
  chore: Add test for eddsa (#2237)
  chore: Split `Nargo.toml` operations into separate package (#2224)
  ...
@TomAFrench
Copy link
Member Author

Bumping this.

sirasistant
sirasistant previously approved these changes Aug 11, 2023
Copy link
Contributor

@sirasistant sirasistant left a comment

Choose a reason for hiding this comment

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

LGTM, could you add a comment pointing to the issue of applying optimizations before brillig gen so we remove this optimization in acir_gen after that issue is done?

* master:
  fix: Fix assignment when both `mut` and `&mut` are used (#2264)
  feat: Add `assert_constant` (#2242)
@kevaundray kevaundray added this pull request to the merge queue Aug 11, 2023
Merged via the queue into master with commit 79af8e6 Aug 11, 2023
15 checks passed
@kevaundray kevaundray deleted the constant-brillig-execution branch August 11, 2023 18:05
TomAFrench added a commit that referenced this pull request Aug 15, 2023
* master:
  chore: Reuse workspace target directory in wasm build script (#2312)
  feat(nargo): Add `--workspace` flag to run commands in every package (#2313)
  chore(frontend): Replace `ModuleOrigin` with `Location` on `ModuleData` (#2308)
  fix: Fix 3 parser test cases in parsing (#2284)
  fix: Require package names to be non-empty (#2293)
  fix(nargo)!: Remove `-p` short flag from the `--program-dir` flag (#2300)
  feat: optionally output a debug artifact on compile (#2260)
  chore: `nargo info` now prints information as a prettified table  (#2282)
  fix(lsp): Pass `--program-dir` to test command from codelens (#2292)
  fix(nargo): Allow `--program-dir` flag anywhere in a command (#2290)
  feat: Execute brillig opcodes with constant inputs at compile-time (#2190)
  feat: Add basic benchmarking (#2213)
  feat: Include struct names in ABIs (#2266)
  feat(nargo): Add `--exact` flag to `nargo test` (#2272)
TomAFrench added a commit that referenced this pull request Aug 15, 2023
* master: (23 commits)
  chore: Reuse workspace target directory in wasm build script (#2312)
  feat(nargo): Add `--workspace` flag to run commands in every package (#2313)
  chore(frontend): Replace `ModuleOrigin` with `Location` on `ModuleData` (#2308)
  fix: Fix 3 parser test cases in parsing (#2284)
  fix: Require package names to be non-empty (#2293)
  fix(nargo)!: Remove `-p` short flag from the `--program-dir` flag (#2300)
  feat: optionally output a debug artifact on compile (#2260)
  chore: `nargo info` now prints information as a prettified table  (#2282)
  fix(lsp): Pass `--program-dir` to test command from codelens (#2292)
  fix(nargo): Allow `--program-dir` flag anywhere in a command (#2290)
  feat: Execute brillig opcodes with constant inputs at compile-time (#2190)
  feat: Add basic benchmarking (#2213)
  feat: Include struct names in ABIs (#2266)
  feat(nargo): Add `--exact` flag to `nargo test` (#2272)
  fix: Fix assignment when both `mut` and `&mut` are used (#2264)
  feat: Add `assert_constant` (#2242)
  feat(nargo): Add support for contracts in `nargo check` (#2267)
  chore(ci): Name wasm job more clearly (#2269)
  chore(ci): Create cache key with consideration to target (#2273)
  chore(ci): Run publish workflow against PRs (#2268)
  ...
TomAFrench added a commit that referenced this pull request Aug 15, 2023
* master: (26 commits)
  chore(noir): Release 0.10.0 (#2039)
  fix(lsp): Ensure lsp does not crawl past the root specified (#2322)
  fix: Prevent panic when passing relative paths to `--program-dir` (#2324)
  fix: Overflowing assignment will result in an error (#2321)
  chore: clippy fixes (#2320)
  chore: Parameterize the build mode for noir-wasm (#2317)
  chore: Make `wasm` tests pull from `result` directory (#2319)
  chore: Fix typo (#2315)
  chore: Reuse workspace target directory in wasm build script (#2312)
  feat(nargo): Add `--workspace` flag to run commands in every package (#2313)
  chore(frontend): Replace `ModuleOrigin` with `Location` on `ModuleData` (#2308)
  fix: Fix 3 parser test cases in parsing (#2284)
  fix: Require package names to be non-empty (#2293)
  fix(nargo)!: Remove `-p` short flag from the `--program-dir` flag (#2300)
  feat: optionally output a debug artifact on compile (#2260)
  chore: `nargo info` now prints information as a prettified table  (#2282)
  fix(lsp): Pass `--program-dir` to test command from codelens (#2292)
  fix(nargo): Allow `--program-dir` flag anywhere in a command (#2290)
  feat: Execute brillig opcodes with constant inputs at compile-time (#2190)
  feat: Add basic benchmarking (#2213)
  ...
jfecher added a commit that referenced this pull request Aug 16, 2023
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.

Execute any Brillig opcodes which have constant inputs at compile time
4 participants