bugfix(lowering): propagate snapshot pop success values#9783
bugfix(lowering): propagate snapshot pop success values#9783jcastil0 wants to merge 3 commits intostarkware-libs:mainfrom
Conversation
orizi
left a comment
There was a problem hiding this comment.
@orizi made 1 comment.
Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on jcastil0).
crates/cairo-lang-lowering/src/optimizations/const_folding_test.rs line 90 at r1 (raw file):
} fn alloc_var<'db>(
add a test in the const_folding test file - not a specialized test for your case.
Moved it into the shared const_folding test file and dropped the specialized test.
@orizi Hi |
Summary
Propagate known values through
array_snapshot_pop_frontandarray_snapshot_pop_backon the success path during const folding, so later lowering passes can keep folding the remaining snapshot array and the popped boxed snapshot.Type of change
Please check one:
Why is this change needed?
Const folding already tracks empty
array_snapshot_pop_front/array_snapshot_pop_backcases, but it drops the known values on the non-empty success path.As a result, later lowering optimization cannot keep folding operations that consume the remaining snapshot array or the popped element, even when both are fully known at compile time.
What was the behavior or documentation before?
For known non-empty snapshot arrays, const folding did not propagate the success outputs of
array_snapshot_pop_frontandarray_snapshot_pop_back.The empty path kept shape information, but the success path lost it.
What is the behavior or documentation after?
For known non-empty snapshot arrays, const folding now propagates:
Box<@T>to the second success outputRelated issue or discussion (if any)
Additional context
This change stays within lowering const-folding and adds focused tests for both
array_snapshot_pop_frontandarray_snapshot_pop_backsuccess paths.Note
Medium Risk
Touches lowering const-folding logic for
array_snapshot_pop_front/back, which can affect compile-time evaluation and downstream optimizations if the propagatedVarInfois wrong, but scope is limited to these two libfuncs.Overview
Const folding now propagates the success-path outputs of
array_snapshot_pop_front/array_snapshot_pop_back: it tracks the remaining snapshot array and the popped element (asBox<@T>), instead of dropping this information on non-empty arrays.Adds focused optimizer test cases asserting that these propagated values enable further folding (e.g., folding two pops on a known
[1, 2]snapshot to a constant result).Written by Cursor Bugbot for commit 1db7cc2. This will update automatically on new commits. Configure here.