@@ -63,21 +63,17 @@ struct simplify_expr_cachet
63
63
simplify_expr_cachet simplify_expr_cache;
64
64
#endif
65
65
66
- bool simplify_exprt::simplify_abs (exprt &expr)
66
+ simplify_exprt::resultt<> simplify_exprt::simplify_abs (const abs_exprt &expr)
67
67
{
68
- if (expr.operands ().size ()!=1 )
69
- return true ;
70
-
71
- if (to_unary_expr (expr).op ().is_constant ())
68
+ if (expr.op ().is_constant ())
72
69
{
73
70
const typet &type = to_unary_expr (expr).op ().type ();
74
71
75
72
if (type.id ()==ID_floatbv)
76
73
{
77
74
ieee_floatt value (to_constant_expr (to_unary_expr (expr).op ()));
78
75
value.set_sign (false );
79
- expr=value.to_expr ();
80
- return false ;
76
+ return value.to_expr ();
81
77
}
82
78
else if (type.id ()==ID_signedbv ||
83
79
type.id ()==ID_unsignedbv)
@@ -87,20 +83,18 @@ bool simplify_exprt::simplify_abs(exprt &expr)
87
83
{
88
84
if (*value >= 0 )
89
85
{
90
- expr = to_unary_expr (expr).op ();
91
- return false ;
86
+ return to_unary_expr (expr).op ();
92
87
}
93
88
else
94
89
{
95
90
value->negate ();
96
- expr = from_integer (*value, type);
97
- return false ;
91
+ return from_integer (*value, type);
98
92
}
99
93
}
100
94
}
101
95
}
102
96
103
- return true ;
97
+ return unchanged (expr) ;
104
98
}
105
99
106
100
bool simplify_exprt::simplify_sign (exprt &expr)
@@ -2528,7 +2522,14 @@ bool simplify_exprt::simplify_node(exprt &expr)
2528
2522
else if (expr.id ()==ID_isnormal)
2529
2523
no_change = simplify_isnormal (expr) && no_change;
2530
2524
else if (expr.id ()==ID_abs)
2531
- no_change = simplify_abs (expr) && no_change;
2525
+ {
2526
+ auto r = simplify_abs (to_abs_expr (expr));
2527
+ if (r.has_changed ())
2528
+ {
2529
+ no_change = false ;
2530
+ expr = r.expr ;
2531
+ }
2532
+ }
2532
2533
else if (expr.id ()==ID_sign)
2533
2534
no_change = simplify_sign (expr) && no_change;
2534
2535
else if (expr.id () == ID_popcount)
0 commit comments