File tree 2 files changed +29
-0
lines changed
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -2303,6 +2303,32 @@ bool simplify_exprt::simplify_byte_update(byte_update_exprt &expr)
2303
2303
return true ;
2304
2304
}
2305
2305
2306
+ bool simplify_exprt::simplify_complex (exprt &expr)
2307
+ {
2308
+ if (expr.id () == ID_complex_real)
2309
+ {
2310
+ complex_real_exprt &complex_real_expr = to_complex_real_expr (expr);
2311
+
2312
+ if (complex_real_expr.op ().id () == ID_complex)
2313
+ {
2314
+ expr = to_complex_expr (complex_real_expr.op ()).real ();
2315
+ return false ;
2316
+ }
2317
+ }
2318
+ else if (expr.id () == ID_complex_imag)
2319
+ {
2320
+ complex_imag_exprt &complex_imag_expr = to_complex_imag_expr (expr);
2321
+
2322
+ if (complex_imag_expr.op ().id () == ID_complex)
2323
+ {
2324
+ expr = to_complex_expr (complex_imag_expr.op ()).imag ();
2325
+ return false ;
2326
+ }
2327
+ }
2328
+
2329
+ return true ;
2330
+ }
2331
+
2306
2332
bool simplify_exprt::simplify_node_preorder (exprt &expr)
2307
2333
{
2308
2334
bool result=true ;
@@ -2445,6 +2471,8 @@ bool simplify_exprt::simplify_node(exprt &expr)
2445
2471
result = simplify_popcount (to_popcount_expr (expr)) && result;
2446
2472
else if (expr.id () == ID_function_application)
2447
2473
result = simplify_function_application (expr) && result;
2474
+ else if (expr.id () == ID_complex_real || expr.id () == ID_complex_imag)
2475
+ result = simplify_complex (expr) && result;
2448
2476
2449
2477
#ifdef DEBUGX
2450
2478
if (!result
Original file line number Diff line number Diff line change @@ -113,6 +113,7 @@ class simplify_exprt
113
113
bool simplify_abs (exprt &expr);
114
114
bool simplify_sign (exprt &expr);
115
115
bool simplify_popcount (popcount_exprt &expr);
116
+ bool simplify_complex (exprt &expr);
116
117
117
118
// / Attempt to simplify mathematical function applications if we have
118
119
// / enough information to do so. Currently focused on constant comparisons.
You can’t perform that action at this time.
0 commit comments