@@ -127,7 +127,8 @@ bool simplify_exprt::simplify_sign(exprt &expr)
127
127
return true ;
128
128
}
129
129
130
- bool simplify_exprt::simplify_popcount (popcount_exprt &expr)
130
+ simplify_exprt::resultt<>
131
+ simplify_exprt::simplify_popcount (const popcount_exprt &expr)
131
132
{
132
133
const exprt &op = expr.op ();
133
134
@@ -145,14 +146,11 @@ bool simplify_exprt::simplify_popcount(popcount_exprt &expr)
145
146
if (get_bvrep_bit (value, width, i))
146
147
result++;
147
148
148
- auto result_expr = from_integer (result, expr.type ());
149
- expr.swap (result_expr);
150
-
151
- return false ;
149
+ return from_integer (result, expr.type ());
152
150
}
153
151
}
154
152
155
- return true ;
153
+ return unchanged (expr) ;
156
154
}
157
155
158
156
bool simplify_exprt::simplify_function_application (exprt &expr)
@@ -2533,7 +2531,14 @@ bool simplify_exprt::simplify_node(exprt &expr)
2533
2531
else if (expr.id ()==ID_sign)
2534
2532
no_change = simplify_sign (expr) && no_change;
2535
2533
else if (expr.id () == ID_popcount)
2536
- no_change = simplify_popcount (to_popcount_expr (expr)) && no_change;
2534
+ {
2535
+ auto r = simplify_popcount (to_popcount_expr (expr));
2536
+ if (r.has_changed ())
2537
+ {
2538
+ no_change = false ;
2539
+ expr = r.expr ;
2540
+ }
2541
+ }
2537
2542
else if (expr.id () == ID_function_application)
2538
2543
no_change = simplify_function_application (expr) && no_change;
2539
2544
else if (expr.id () == ID_complex_real || expr.id () == ID_complex_imag)
0 commit comments