fix(acir-gen): Use current side effect predicate in memory ops for slices#9471
fix(acir-gen): Use current side effect predicate in memory ops for slices#9471
Conversation
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark 'Execution Time'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.
| Benchmark suite | Current: 86c73a7 | Previous: e54057d | Ratio |
|---|---|---|---|
private-kernel-inner |
0.016 s |
0.013 s |
1.23 |
This comment was automatically generated by workflow using github-action-benchmark.
CC: @TomAFrench
TomAFrench
left a comment
There was a problem hiding this comment.
The predicate on memory ops is currently ignored by barretenberg and is being removed in #8134
|
@TomAFrench thanks for the heads up. Should I insert constraints into the SSA the way we do for Brillig then? |
|
Yeah, I think we're going to need to explicitly guard in cases where the slice length can potentially go to zero. |
|
Okay, I'll close this and open an alternative PR. A quick test with adding the same intrinsic call check as we did in Brillig revealed that it won't work on its own for ACIR. It resuls in an SSA like this: So it requires that we don't go into the I'll see if we can somehow reason about being under a predicate in |
|
Closing in favour of #9489 |
Description
Problem*
Resolves #9467
Summary*
Changes the SSA-to-ACIR codegen handling of
Intrinsics::SlicePopFrontand other slice operations to passcurrent_side_effects_varwhen creating the ACIROpcode::MemoryOp, so that if side effects are disabled, then nothing happens. This way trying to pop from an empty slice on a disabled branch doesn't cause circuit failure.Failing circuit size calculations in BB
There is some strange failure somewhere in bb.
Additional Context
I'm not sure why the same predicate wasn't used before for array operations. I only enabled it for slices, because for arrays the predicate seems to become part of the indexing itself.
Another approach would be to insert constraints into SSA like in #9323 but in that PR we discussed that these should only be required for Brillig, so I thought ACIR should be able to handle this without extra constraints.
Yet another alternative would be for
remove_unreachable_instructionsto look for 0 size, but I figured that would i) fragment the knowledge about these intrinsics even further, ii) it wouldn't be much different from inserting the constraints up front and iii) wouldn't cover popping from slices where the compiler doesn't statically know that the size is 0.With these changes the ACIR for the program in the bug ticket looks like this:
Documentation*
Check one:
PR Checklist*
cargo fmton default settings.