@@ -661,8 +661,7 @@ simplify_exprt::simplify_typecast(const typecast_exprt &expr)
661
661
op_type.id () == ID_pointer && expr.op ().id () == ID_plus &&
662
662
expr.op ().operands ().size () == 2 &&
663
663
((expr.op ().op0 ().id () == ID_typecast &&
664
- expr.op ().op0 ().operands ().size () == 1 &&
665
- expr.op ().op0 ().op0 ().is_zero ()) ||
664
+ to_typecast_expr (expr.op ().op0 ()).op ().is_zero ()) ||
666
665
(expr.op ().op0 ().is_constant () &&
667
666
to_constant_expr (expr.op ().op0 ()).get_value () == ID_NULL)))
668
667
{
@@ -1076,14 +1075,14 @@ simplify_exprt::simplify_typecast(const typecast_exprt &expr)
1076
1075
{
1077
1076
// (T1)(T2)x ---> (T1)
1078
1077
// where T1 has fewer bits than T2
1079
- if (operand. operands (). size ()== 1 &&
1080
- op_type_id== expr_type_id &&
1081
- (expr_type_id== ID_unsignedbv || expr_type_id== ID_signedbv) &&
1082
- to_bitvector_type (expr_type).get_width ()<=
1083
- to_bitvector_type (operand.type ()).get_width ())
1078
+ if (
1079
+ op_type_id == expr_type_id &&
1080
+ (expr_type_id == ID_unsignedbv || expr_type_id == ID_signedbv) &&
1081
+ to_bitvector_type (expr_type).get_width () <=
1082
+ to_bitvector_type (operand.type ()).get_width ())
1084
1083
{
1085
1084
auto new_expr = expr;
1086
- new_expr.op () = expr. op (). op0 ();
1085
+ new_expr.op () = to_typecast_expr (operand). op ();
1087
1086
// might enable further simplification
1088
1087
return changed (simplify_typecast (new_expr)); // recursive call
1089
1088
}
@@ -1139,9 +1138,9 @@ simplify_exprt::simplify_dereference(const dereference_exprt &expr)
1139
1138
return changed (simplify_rec (tmp));
1140
1139
}
1141
1140
// rewrite *(&a[0] + x) to a[x]
1142
- else if (pointer. id ()==ID_plus &&
1143
- pointer.operands ().size ()== 2 &&
1144
- pointer.op0 ().id ()== ID_address_of)
1141
+ else if (
1142
+ pointer. id () == ID_plus && pointer.operands ().size () == 2 &&
1143
+ to_plus_expr ( pointer) .op0 ().id () == ID_address_of)
1145
1144
{
1146
1145
const address_of_exprt &address_of=
1147
1146
to_address_of_expr (pointer.op0 ());
0 commit comments