Skip to content

feat: Optimize equality checks between a boolean and constant#2201

Merged
TomAFrench merged 3 commits intomasterfrom
simplify-bool-eq-true
Aug 7, 2023
Merged

feat: Optimize equality checks between a boolean and constant#2201
TomAFrench merged 3 commits intomasterfrom
simplify-bool-eq-true

Conversation

@TomAFrench
Copy link
Member

Description

Problem*

Resolves

Summary*

This PR adds an optimisation such that any expressions of the form boolean == true get simplified into boolean. This is aimed at making assert(boolean == true) not do 2 rounds of creating a new variable and constraining it to be equal to 1.

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 requested review from jfecher and phated August 7, 2023 17:51
jfecher
jfecher previously approved these changes Aug 7, 2023
@TomAFrench
Copy link
Member Author

One sec, I just realised we can do the same for bool == false

@TomAFrench TomAFrench requested a review from jfecher August 7, 2023 18:15
@TomAFrench TomAFrench changed the title feat: Optimize away any equality checks between a boolean and true feat: Optimize equality checks between a boolean and constant Aug 7, 2023
@TomAFrench TomAFrench added this pull request to the merge queue Aug 7, 2023
Merged via the queue into master with commit 478c026 Aug 7, 2023
@TomAFrench TomAFrench deleted the simplify-bool-eq-true branch August 7, 2023 18:46
TomAFrench added a commit that referenced this pull request Aug 7, 2023
* 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)
TomAFrench added a commit that referenced this pull request Aug 7, 2023
* master:
  chore: dumb integration of binary constrain
  fix: Set location before cast instructions in SSA (#2202)
  fix: simplification of overflowing integer operations (#2153)
  feat: Optimize equality checks between a boolean and constant (#2201)
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.

2 participants