@@ -1215,11 +1215,6 @@ bool simplify_exprt::simplify_inequality(exprt &expr)
1215
1215
(expr.id ()==ID_equal || expr.id ()==ID_notequal))
1216
1216
return simplify_inequality_pointer_object (expr);
1217
1217
1218
- // first see if we compare to a constant
1219
-
1220
- bool op0_is_const=tmp0.is_constant ();
1221
- bool op1_is_const=tmp1.is_constant ();
1222
-
1223
1218
ns.follow_symbol (tmp0.type ());
1224
1219
ns.follow_symbol (tmp1.type ());
1225
1220
@@ -1229,9 +1224,20 @@ bool simplify_exprt::simplify_inequality(exprt &expr)
1229
1224
if (tmp1.type ().id ()==ID_c_enum_tag)
1230
1225
tmp1.type ()=ns.follow_tag (to_c_enum_tag_type (tmp1.type ()));
1231
1226
1227
+ const auto tmp0_const = expr_try_dynamic_cast<constant_exprt>(tmp0);
1228
+ const auto tmp1_const = expr_try_dynamic_cast<constant_exprt>(tmp1);
1229
+
1232
1230
// are _both_ constant?
1233
- if (op0_is_const && op1_is_const )
1231
+ if (tmp0_const && tmp1_const )
1234
1232
{
1233
+ if (expr.id () == ID_equal || expr.id () == ID_notequal)
1234
+ {
1235
+
1236
+ bool equal = (tmp0_const->get_value () == tmp1_const->get_value ());
1237
+ expr.make_bool (expr.id () == ID_equal ? equal : !equal);
1238
+ return false ;
1239
+ }
1240
+
1235
1241
if (tmp0.type ().id ()==ID_bool)
1236
1242
{
1237
1243
bool v0=tmp0.is_true ();
@@ -1347,7 +1353,7 @@ bool simplify_exprt::simplify_inequality(exprt &expr)
1347
1353
return false ;
1348
1354
}
1349
1355
}
1350
- else if (op0_is_const )
1356
+ else if (tmp0_const )
1351
1357
{
1352
1358
// we want the constant on the RHS
1353
1359
@@ -1366,7 +1372,7 @@ bool simplify_exprt::simplify_inequality(exprt &expr)
1366
1372
simplify_inequality_constant (expr);
1367
1373
return false ;
1368
1374
}
1369
- else if (op1_is_const )
1375
+ else if (tmp1_const )
1370
1376
{
1371
1377
// one is constant
1372
1378
return simplify_inequality_constant (expr);
0 commit comments