chore: resolve Instruction inputs fully before checking against cache#2472
chore: resolve Instruction inputs fully before checking against cache#2472
Instruction inputs fully before checking against cache#2472Conversation
Instruction inputs fully before checking against cache
@vezenovm and I did find a few bugs yesterday in that the DIE pass' definition of a side-effectful instruction was different than the definition needed by this pass to remove duplicates. |
|
It seems like |
This PR maps the instruction inputs values, so perhaps there are two truncates on the same value where one instruction truncates to a smaller bit size. The smaller truncation comes second in line, so the value is replaced with values that have too large of a bit size. Seems to be another case of the DIE pass' definition of an instruction with side-effects differs from that definition in this pass. |
|
The target bitsize is part of the key on the cache though so I would expect that situation not to cause troubles. In any case, now we know it's truncation instructions I'll have a closer look at how these are being optimized out. |
|
I'm happy to merge this without |
|
I'd like to put this into a non-breaking release today before we start merging in the changes from |
jfecher
left a comment
There was a problem hiding this comment.
is_pure is a good addition
* master: (42 commits) fix(ssa): Handle right shift with constants (#2481) chore(noir): Release 0.10.4 (#2354) fix: Divide by zero should fail to satisfy constraints for `Field` and ints (#2475) fix(ssa): Remove padding from ToRadix call with constant inputs (#2479) fix: Implement handling of array aliasing in the mem2reg optimization pass (#2463) chore: resolve `Instruction` inputs fully before checking against cache (#2472) chore: Move independent `run_test` function into nargo core (#2468) feat: Standard library functions can now be called with closure args (#2471) feat(frontend): aztec syntactic sugar (feature flagged) (#2403) chore(ci): enforce compliance with `cargo fmt` (#2467) chore(ci): Allow releases to have additional feature flags (#2405) feat: Add `assert_eq` keyword (#2137) fix(ssa): Do not optimize for allocates in constant folding (#2466) feat(ssa): Reuse existing results for duplicated instructions with no side-effects (#2460) fix: Closure lvalue capture bugfix (#2457) feat: Syntax for environment types now works with generics (#2383) fix(parser): fixes for the parsing of 'where' clauses (#2430) fix: Run `wasm` nodejs tests with no fails (#2387) chore: Run `cargo fmt` (#2455) chore: Perform formatting changes to integration tests (#2448) ...
* master: (42 commits) fix(ssa): Handle right shift with constants (#2481) chore(noir): Release 0.10.4 (#2354) fix: Divide by zero should fail to satisfy constraints for `Field` and ints (#2475) fix(ssa): Remove padding from ToRadix call with constant inputs (#2479) fix: Implement handling of array aliasing in the mem2reg optimization pass (#2463) chore: resolve `Instruction` inputs fully before checking against cache (#2472) chore: Move independent `run_test` function into nargo core (#2468) feat: Standard library functions can now be called with closure args (#2471) feat(frontend): aztec syntactic sugar (feature flagged) (#2403) chore(ci): enforce compliance with `cargo fmt` (#2467) chore(ci): Allow releases to have additional feature flags (#2405) feat: Add `assert_eq` keyword (#2137) fix(ssa): Do not optimize for allocates in constant folding (#2466) feat(ssa): Reuse existing results for duplicated instructions with no side-effects (#2460) fix: Closure lvalue capture bugfix (#2457) feat: Syntax for environment types now works with generics (#2383) fix(parser): fixes for the parsing of 'where' clauses (#2430) fix: Run `wasm` nodejs tests with no fails (#2387) chore: Run `cargo fmt` (#2455) chore: Perform formatting changes to integration tests (#2448) ...
Description
Problem*
Resolves
Summary*
It struck me that we should be fully resolving any inputs to the instruction before we check against the cache. This allows us to catch the maximum amount of duplicate instructions.
What's concerning is that I'm now getting a failed constraint error in the
sha2tests. This seems otherwise a fairly low-risk change so I'm not sure if there's a deeper issue in #2450 which wasn't caught which means we should revert that change. @jfecher what do you think?Documentation
This PR requires documentation updates when merged.
Additional Context
PR Checklist*
cargo fmton default settings.