@@ -8,6 +8,7 @@ Author: Michael Tautschnig
88
99#include < util/arith_tools.h>
1010#include < util/bitvector_expr.h>
11+ #include < util/bitvector_types.h>
1112#include < util/byte_operators.h>
1213#include < util/c_types.h>
1314#include < util/cmdline.h>
@@ -652,3 +653,51 @@ TEST_CASE("Simplify quantifier", "[core][util]")
652653 REQUIRE (simplify_expr (forall_exprt{a, true_exprt{}}, ns) == true_exprt{});
653654 }
654655}
656+
657+ TEST_CASE (" Simplify all-zero constant in bitand" , " [core][util]" )
658+ {
659+ const symbol_tablet symbol_table;
660+ const namespacet ns{symbol_table};
661+
662+ const unsignedbv_typet u8 {8 };
663+ const symbol_exprt x{" x" , u8 };
664+ const auto zero = from_integer (0 , u8 );
665+ const bitand_exprt band{x, zero};
666+ REQUIRE (simplify_expr (band, ns) == zero);
667+ }
668+
669+ TEST_CASE (" Simplify all-ones constant in bitor" , " [core][util]" )
670+ {
671+ const symbol_tablet symbol_table;
672+ const namespacet ns{symbol_table};
673+
674+ const unsignedbv_typet u8 {8 };
675+ const symbol_exprt x{" x" , u8 };
676+ const auto ones = from_integer (255 , u8 );
677+ const bitor_exprt bor{x, ones};
678+ REQUIRE (simplify_expr (bor, ns) == ones);
679+ }
680+
681+ TEST_CASE (" Simplify all-zero constant in bitand with bv_typet" , " [core][util]" )
682+ {
683+ const symbol_tablet symbol_table;
684+ const namespacet ns{symbol_table};
685+
686+ const bv_typet bv8{8 };
687+ const symbol_exprt x{" x" , bv8};
688+ const auto zero = bv8.all_zeros_expr ();
689+ const bitand_exprt band{x, zero};
690+ REQUIRE (simplify_expr (band, ns) == zero);
691+ }
692+
693+ TEST_CASE (" Simplify all-ones constant in bitor with bv_typet" , " [core][util]" )
694+ {
695+ const symbol_tablet symbol_table;
696+ const namespacet ns{symbol_table};
697+
698+ const bv_typet bv8{8 };
699+ const symbol_exprt x{" x" , bv8};
700+ const auto ones = bv8.all_ones_expr ();
701+ const bitor_exprt bor{x, ones};
702+ REQUIRE (simplify_expr (bor, ns) == ones);
703+ }
0 commit comments