File tree Expand file tree Collapse file tree 6 files changed +28
-83
lines changed
regression/cbmc/inequality-with-constant-normalisation1 Expand file tree Collapse file tree 6 files changed +28
-83
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,6 @@ ForEachMacros: [
5454 ' Forall_irep' ,
5555 ' forall_named_irep' ,
5656 ' Forall_named_irep' ,
57- ' forall_value_list' ,
5857 ' forall_symbol_base_map' ,
5958 ' forall_subtypes' ,
6059 ' Forall_subtypes' ]
Original file line number Diff line number Diff line change 1+ #include <assert.h>
2+
3+ #ifdef _MSC_VER
4+ # define _Static_assert (x , m ) static_assert(x, m)
5+ #endif
6+
7+ int main ()
8+ {
9+ _Bool b1 , b2 ;
10+
11+ int nc = (b1 ? 1 : 2 ) == (b2 ? 1 : 2 );
12+ assert (b1 != b2 || nc != 0 );
13+
14+ // The following are true for all values of b1, b2, and the simplifier should
15+ // be able to figure this out.
16+ _Static_assert ((b1 ? 1 : 1 ) == (b2 ? 1 : 1 ), "" );
17+ _Static_assert (((b1 ? 2 : 3 ) >= (b2 ? 1 : 2 )) != 0 , "" );
18+ _Static_assert (((b1 ? 0 : 1 ) >= (b2 ? 2 : 3 )) == 0 , "" );
19+ _Static_assert (((b1 ? 0 : 1 ) >= 2 ) == 0 , "" );
20+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ main.c
3+
4+ ^EXIT=0$
5+ ^SIGNAL=0$
6+ ^VERIFICATION SUCCESSFUL$
7+ --
8+ ^warning: ignoring
Original file line number Diff line number Diff line change @@ -1331,31 +1331,6 @@ simplify_exprt::simplify_dereference(const dereference_exprt &expr)
13311331 return unchanged (expr);
13321332}
13331333
1334- bool simplify_exprt::get_values (
1335- const exprt &expr,
1336- value_listt &value_list)
1337- {
1338- if (expr.is_constant ())
1339- {
1340- mp_integer int_value;
1341- if (to_integer (to_constant_expr (expr), int_value))
1342- return true ;
1343-
1344- value_list.insert (int_value);
1345-
1346- return false ;
1347- }
1348- else if (expr.id ()==ID_if)
1349- {
1350- const auto &if_expr = to_if_expr (expr);
1351-
1352- return get_values (if_expr.true_case (), value_list) ||
1353- get_values (if_expr.false_case (), value_list);
1354- }
1355-
1356- return true ;
1357- }
1358-
13591334simplify_exprt::resultt<>
13601335simplify_exprt::simplify_lambda (const lambda_exprt &expr)
13611336{
Original file line number Diff line number Diff line change @@ -66,10 +66,6 @@ class unary_plus_exprt;
6666class update_exprt ;
6767class with_exprt ;
6868
69- #define forall_value_list (it, value_list ) \
70- for (simplify_exprt::value_listt::const_iterator it=(value_list).begin(); \
71- it!=(value_list).end(); ++it)
72-
7369class simplify_exprt
7470{
7571public:
@@ -221,9 +217,6 @@ class simplify_exprt
221217
222218 virtual bool simplify (exprt &expr);
223219
224- typedef std::set<mp_integer> value_listt;
225- bool get_values (const exprt &expr, value_listt &value_list);
226-
227220 static bool is_bitvector_type (const typet &type)
228221 {
229222 return type.id ()==ID_unsignedbv ||
Original file line number Diff line number Diff line change @@ -1513,56 +1513,6 @@ simplify_exprt::resultt<> simplify_exprt::simplify_inequality_no_constant(
15131513 if (expr.op0 () == expr.op1 ())
15141514 return true_exprt ();
15151515
1516- // try constants
1517-
1518- value_listt values0, values1;
1519-
1520- bool ok0=!get_values (expr.op0 (), values0);
1521- bool ok1=!get_values (expr.op1 (), values1);
1522-
1523- if (ok0 && ok1)
1524- {
1525- bool first=true ;
1526- bool result=false ; // dummy initialization to prevent warning
1527- bool ok=true ;
1528-
1529- // compare possible values
1530-
1531- forall_value_list (it0, values0)
1532- forall_value_list (it1, values1)
1533- {
1534- bool tmp;
1535- const mp_integer &int_value0=*it0;
1536- const mp_integer &int_value1=*it1;
1537-
1538- if (expr.id ()==ID_ge)
1539- tmp=(int_value0>=int_value1);
1540- else if (expr.id ()==ID_equal)
1541- tmp=(int_value0==int_value1);
1542- else
1543- {
1544- tmp=false ;
1545- UNREACHABLE;
1546- }
1547-
1548- if (first)
1549- {
1550- result=tmp;
1551- first=false ;
1552- }
1553- else if (result!=tmp)
1554- {
1555- ok=false ;
1556- break ;
1557- }
1558- }
1559-
1560- if (ok)
1561- {
1562- return make_boolean_expr (result);
1563- }
1564- }
1565-
15661516 // See if we can eliminate common addends on both sides.
15671517 // On bit-vectors, this is only sound on '='.
15681518 if (expr.id ()==ID_equal)
You can’t perform that action at this time.
0 commit comments