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: [
54
54
' Forall_irep' ,
55
55
' forall_named_irep' ,
56
56
' Forall_named_irep' ,
57
- ' forall_value_list' ,
58
57
' forall_symbol_base_map' ,
59
58
' forall_subtypes' ,
60
59
' 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)
1331
1331
return unchanged (expr);
1332
1332
}
1333
1333
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
-
1359
1334
simplify_exprt::resultt<>
1360
1335
simplify_exprt::simplify_lambda (const lambda_exprt &expr)
1361
1336
{
Original file line number Diff line number Diff line change @@ -66,10 +66,6 @@ class unary_plus_exprt;
66
66
class update_exprt ;
67
67
class with_exprt ;
68
68
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
-
73
69
class simplify_exprt
74
70
{
75
71
public:
@@ -221,9 +217,6 @@ class simplify_exprt
221
217
222
218
virtual bool simplify (exprt &expr);
223
219
224
- typedef std::set<mp_integer> value_listt;
225
- bool get_values (const exprt &expr, value_listt &value_list);
226
-
227
220
static bool is_bitvector_type (const typet &type)
228
221
{
229
222
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(
1513
1513
if (expr.op0 () == expr.op1 ())
1514
1514
return true_exprt ();
1515
1515
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
-
1566
1516
// See if we can eliminate common addends on both sides.
1567
1517
// On bit-vectors, this is only sound on '='.
1568
1518
if (expr.id ()==ID_equal)
You can’t perform that action at this time.
0 commit comments