Skip to content

Rewrite byte_extract from multi-dimensional array#8705

Merged
tautschnig merged 1 commit intodiffblue:developfrom
tautschnig:byte_extract-multi-dim-array
Apr 12, 2026
Merged

Rewrite byte_extract from multi-dimensional array#8705
tautschnig merged 1 commit intodiffblue:developfrom
tautschnig:byte_extract-multi-dim-array

Conversation

@tautschnig
Copy link
Copy Markdown
Collaborator

@tautschnig tautschnig commented Aug 6, 2025

As a follow-up to 78839a9: add support for rewriting multiple-of-element size access to arrays when working with multi-dimensional arrays.

Fixes: #8796

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.48%. Comparing base (cd64a96) to head (d5b671e).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8705   +/-   ##
========================================
  Coverage    80.47%   80.48%           
========================================
  Files         1704     1704           
  Lines       188762   188774   +12     
  Branches        73       73           
========================================
+ Hits        151908   151936   +28     
+ Misses       36854    36838   -16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tautschnig tautschnig self-assigned this Oct 20, 2025
@tautschnig tautschnig force-pushed the byte_extract-multi-dim-array branch from 0ae1c7e to 9a19114 Compare December 10, 2025 14:40
@tautschnig
Copy link
Copy Markdown
Collaborator Author

Now includes a minified version of the sample provided in #8796 to confirm the desired effect of the simplification improvement.

@tautschnig tautschnig force-pushed the byte_extract-multi-dim-array branch 5 times, most recently from 15e460c to 4f514db Compare December 10, 2025 15:57
@rod-chapman
Copy link
Copy Markdown
Collaborator

Can we push this to the top of the queue to be reviewed please? This is blocking progress on mldsa-native.

@rod-chapman
Copy link
Copy Markdown
Collaborator

Regression testing with mlkem-native and mldsa-native (all parameter sets) is good at the HEAD of this branch now.

I have also tested the specific test case added for Issue #8796 with good results.

Please rebase and merge.

@tautschnig tautschnig force-pushed the byte_extract-multi-dim-array branch from 81a05fd to a6572b2 Compare April 2, 2026 10:39
@tautschnig tautschnig marked this pull request as ready for review April 2, 2026 10:40
@tautschnig tautschnig requested a review from martin-cs as a code owner April 2, 2026 10:40
Copilot AI review requested due to automatic review settings April 2, 2026 10:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves handling of byte-level extraction and array rewrites for multi-dimensional arrays, and fixes SMT array-theory behavior for let-bound arrays by ensuring fresh let symbols remain connected to their bound arrays.

Changes:

  • Enhance get_subexpression_at_offset to better decompose scaled offsets for multi-dimensional array layouts.
  • In the bit-blaster, record array equalities for let bindings over unbounded arrays so element constraints propagate through the fresh symbol.
  • Add regression tests for SMT2 let over arrays and a DFCC performance/regression scenario involving multi-dimensional arrays.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/util/pointer_offset_size.cpp Adds a new decomposition path for scaled offsets into multi-dimensional arrays; factors out elem_size_bytes.
src/solvers/flattening/boolbv_let.cpp Adds element-wise connection between fresh let symbols and bound unbounded arrays via recorded array equality.
regression/smt2_solver/let-array/let-array.smt2 New SMT2 regression demonstrating required propagation through let-bound arrays.
regression/smt2_solver/let-array/let-array.desc Expected output for the new SMT2 regression.
regression/contracts-dfcc/multi_dimensional_array_performance/test.desc New DFCC regression entry for the multi-dimensional array scenario.
regression/contracts-dfcc/multi_dimensional_array_performance/program.desc Checks produced program output matches expected byte_extract pattern.
regression/contracts-dfcc/multi_dimensional_array_performance/main.c New C harness intended to exercise the multi-dimensional array rewrite path under DFCC.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

mkannwischer added a commit to pq-code-package/mldsa-native that referenced this pull request Apr 12, 2026
diffblue/cbmc#8705
Signed-off-by: Matthias J. Kannwischer <matthias@zerorisc.com>
mkannwischer added a commit to pq-code-package/mldsa-native that referenced this pull request Apr 12, 2026
diffblue/cbmc#8705
Signed-off-by: Matthias J. Kannwischer <matthias@zerorisc.com>
As a follow-up to 78839a9: add support for rewriting
multiple-of-element size access to arrays when working with
multi-dimensional arrays.

Fixes: diffblue#8796
@tautschnig tautschnig merged commit 28b2b72 into diffblue:develop Apr 12, 2026
43 checks passed
@tautschnig tautschnig deleted the byte_extract-multi-dim-array branch April 12, 2026 22:28
tautschnig added a commit to tautschnig/cbmc that referenced this pull request Apr 12, 2026
When byte_extract is applied to a union-typed expression with a
non-constant computed offset, the byte_extract lowering creates a
massive expression because it must consider all possible byte layouts.
For unions where the widest member covers the entire union, we can
instead decompose the access through that member, avoiding the
expensive lowering.

Add union handling to the non-constant-offset overload of
get_subexpression_at_offset: for symbol and member expressions of
union type, recurse into the widest member. Guard this on the widest
member's size equalling the union's size (no trailing padding).

The constant-offset overload is left unchanged to preserve existing
simplification behavior (e.g., byte_extract(byte_update(...))
patterns used during constant propagation).

On the reproducer from diffblue#8813, the union version now takes 1.0s
(previously 94s), matching the struct version at 1.0s.

On the union_performance2 test (poly vec[8] with int32_t
coeffs[256], accessed through a union with --z3), the union version
completes in 0.08s matching the struct equivalent. Without this fix
combined with the multi-dimensional array rewrite from diffblue#8705, the
byte_extract lowering would not terminate within reasonable time.

Fixes: diffblue#8813

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
hanno-becker pushed a commit to pq-code-package/mldsa-native that referenced this pull request Apr 13, 2026
diffblue/cbmc#8705
Signed-off-by: Matthias J. Kannwischer <matthias@zerorisc.com>
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.

Proof/SMT explosion for simple nested loop over 2D array

5 participants