Float constant propagation must observe rounding modes#8772
Open
tautschnig wants to merge 1 commit intodiffblue:developfrom
Open
Float constant propagation must observe rounding modes#8772tautschnig wants to merge 1 commit intodiffblue:developfrom
tautschnig wants to merge 1 commit intodiffblue:developfrom
Conversation
Detect assignments to `__CPROVER_rounding_mode` and invalidate all floating-point constants in the value map. This ensures soundness by preventing the reuse of constants computed with a different rounding mode, at the cost of potentially missing some optimization opportunities. Fixes: diffblue#350
c3dd308 to
9ca26bf
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses unsound float constant propagation when __CPROVER_rounding_mode changes by invalidating cached floating-point constants on rounding-mode assignments, and updates/extends regression and unit tests accordingly.
Changes:
- Detect assignments to
__CPROVER_rounding_modein constant propagation and clear cached float constants. - Add a unit test covering rounding-mode changes and their impact on propagated float constants.
- Add/adjust regression tests to reflect the more conservative (sounder) behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/analyses/constant_propagator.cpp |
Invalidate cached float constants on rounding-mode assignment; add invalidation helper. |
src/analyses/constant_propagator.h |
Declare invalidate_floatbv_constants on the domain value store. |
unit/analyses/constant_propagator.cpp |
Add unit test scenario for rounding-mode changes affecting float constant propagation. |
regression/goto-instrument/constant_propagation_float_rounding_unsound/test.desc |
New regression test driver for the previously-unsound case. |
regression/goto-instrument/constant_propagation_float_rounding_unsound/main.c |
New regression test program exercising rounding-mode change around float division. |
regression/goto-analyzer/constant_propagation_rounding_mode/test.desc |
Update expected outcomes (one assertion becomes UNKNOWN). |
regression/goto-analyzer/constant_propagation_nondet_rounding_mode/test.desc |
Update expected outcomes (more conservative UNKNOWN results). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| // Remove any variable with floating-point type, as its value | ||
| // may have been computed with a different rounding mode | ||
| if(symbol.type.id() == ID_floatbv) |
Comment on lines
+414
to
+423
| THEN( | ||
| "The propagator should NOT have f1 as a constant, because " | ||
| "the rounding mode changed") | ||
| { | ||
| const auto &final_domain = constant_propagator[test_instruction]; | ||
|
|
||
| // f1 should not be constant at this point because the rounding | ||
| // mode changed after it was computed | ||
| REQUIRE_FALSE( | ||
| final_domain.values.is_constant(local_f1.symbol_expr(), ns)); |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8772 +/- ##
========================================
Coverage 80.41% 80.42%
========================================
Files 1703 1703
Lines 188398 188462 +64
Branches 73 73
========================================
+ Hits 151498 151563 +65
+ Misses 36900 36899 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Detect assignments to
__CPROVER_rounding_modeand invalidate all floating-point constants in the value map. This ensures soundness by preventing the reuse of constants computed with a different rounding mode, at the cost of potentially missing some optimization opportunities.Fixes: #350