We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a9fa893 commit 0e2b13fCopy full SHA for 0e2b13f
src/util/simplify_expr.cpp
@@ -240,6 +240,18 @@ bool simplify_exprt::simplify_typecast(exprt &expr)
240
if(expr_type.id()==ID_c_bool &&
241
op_type.id()!=ID_bool)
242
{
243
+ // casts from boolean to a signed int and back:
244
+ // (boolean)(int)boolean -> boolean
245
+ if(expr.op0().id()==ID_typecast && op_type.id()==ID_signedbv)
246
+ {
247
+ const auto &typecast=to_typecast_expr(expr.op0());
248
+ if(typecast.op().type().id()==ID_c_bool)
249
250
+ expr=typecast.op0();
251
+ return false;
252
+ }
253
254
+
255
// rewrite (_Bool)x to (_Bool)(x!=0)
256
binary_relation_exprt inequality;
257
inequality.id(op_type.id()==ID_floatbv?ID_ieee_float_notequal:ID_notequal);
0 commit comments