Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ITE and binary relations are constant when all operands are constants #7569

Merged
merged 1 commit into from
Mar 6, 2023

Conversation

tautschnig
Copy link
Collaborator

This expands the definition of is_constantt to cover if-then-else as well as binary relations. In many, but not, cases the simplifier will have turned these into simpler constants. The included regression test is derived from Rust code, where the intermediate representation (together with constant propagation) will yield such comparisons.

  • 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.

@tautschnig tautschnig added aws Bugs or features of importance to AWS CBMC users Kani Bugs or features of importance to Kani Rust Verifier labels Mar 1, 2023
Copy link
Member

@peterschrammel peterschrammel left a comment

Choose a reason for hiding this comment

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

Does the same reasoning also apply to further operators such as bitwise and boolean operators?

@peterschrammel peterschrammel removed their assignment Mar 2, 2023
@tautschnig tautschnig assigned tautschnig and unassigned kroening Mar 2, 2023
@tautschnig
Copy link
Collaborator Author

Does the same reasoning also apply to further operators such as bitwise and boolean operators?

Good call. Doing something like ptr & 0xF for alignment checks would be such an example that we can safely constant-propagate (once ptr is found to be &object by other constant propagation). Added.

This expands the definition of is_constantt to cover if-then-else as
well as binary relations and logic or bit operations. In many, but not,
cases the simplifier will have turned these into simpler constants. The
included regression test is derived from Rust code, where the
intermediate representation (together with constant propagation) will
yield such comparisons.
@codecov
Copy link

codecov bot commented Mar 6, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.10 🎉

Comparison is base (e024ecb) 78.39% compared to head (0289d31) 78.50%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #7569      +/-   ##
===========================================
+ Coverage    78.39%   78.50%   +0.10%     
===========================================
  Files         1670     1670              
  Lines       191760   191764       +4     
===========================================
+ Hits        150337   150544     +207     
+ Misses       41423    41220     -203     
Impacted Files Coverage Δ
src/util/expr_util.cpp 91.20% <100.00%> (+0.19%) ⬆️
src/util/bitvector_expr.h 97.41% <0.00%> (+0.46%) ⬆️
src/util/symbol_table.cpp 91.30% <0.00%> (+6.52%) ⬆️
src/util/type.h 100.00% <0.00%> (+7.46%) ⬆️
src/util/string_container.h 100.00% <0.00%> (+9.09%) ⬆️
src/util/ssa_expr.h 100.00% <0.00%> (+11.36%) ⬆️
src/util/validate_expressions.cpp 93.75% <0.00%> (+18.75%) ⬆️
src/big-int/bigint.cc 89.00% <0.00%> (+20.50%) ⬆️
src/util/validate_helpers.h 100.00% <0.00%> (+22.22%) ⬆️
src/util/string_container.cpp 51.85% <0.00%> (+27.77%) ⬆️
... and 3 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@tautschnig tautschnig merged commit 014188e into diffblue:develop Mar 6, 2023
@tautschnig tautschnig deleted the feature/more-constants branch March 6, 2023 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws Bugs or features of importance to AWS CBMC users Kani Bugs or features of importance to Kani Rust Verifier
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants