static cast: simplify
authorKazuki Sakamoto <sakamoto@splhack.org>
Sat, 20 Jun 2020 02:09:43 +0000 (19:09 -0700)
committerKazuki Sakamoto <sakamoto@splhack.org>
Sat, 20 Jun 2020 02:09:43 +0000 (19:09 -0700)
frontends/ast/simplify.cc

index 1d5dd91a7ac602012ddd1b1458d09c12c6496071..e2da17c0909ec2cd6e2bea233c2e8e9b093ea2ae 100644 (file)
@@ -3484,6 +3484,13 @@ replace_fcall_later:;
                                }
                        }
                        break;
+               case AST_CAST_SIZE:
+                       if (children.at(0)->type == AST_CONSTANT && children.at(1)->type == AST_CONSTANT) {
+                               int width = children[0]->bitsAsConst().as_int();
+                               RTLIL::Const val = children[1]->bitsAsConst(width);
+                               newNode = mkconst_bits(val.bits, children[1]->is_signed);
+                       }
+                       break;
                case AST_CONCAT:
                        string_op = !children.empty();
                        for (auto it = children.begin(); it != children.end(); it++) {