aboutsummaryrefslogtreecommitdiffstats
path: root/frontends/ast/simplify.cc
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-01-20 20:25:20 +0100
committerClifford Wolf <clifford@clifford.at>2014-01-20 20:25:20 +0100
commit88fbdd4916a9a9f491d22075b63beb676153c3d3 (patch)
tree8b9fba068f056c82b7e1cbe80a56403b33c99f8a /frontends/ast/simplify.cc
parent32a91458a7dde9994ca28ec635c1bec8fe20111b (diff)
downloadyosys-88fbdd4916a9a9f491d22075b63beb676153c3d3.tar.gz
yosys-88fbdd4916a9a9f491d22075b63beb676153c3d3.tar.bz2
yosys-88fbdd4916a9a9f491d22075b63beb676153c3d3.zip
Fixed algorithmic complexity of AST simplification of long expressions
Diffstat (limited to 'frontends/ast/simplify.cc')
-rw-r--r--frontends/ast/simplify.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc
index c266800e9..bd5da14e3 100644
--- a/frontends/ast/simplify.cc
+++ b/frontends/ast/simplify.cc
@@ -237,8 +237,8 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
case AST_ASSIGN_EQ:
case AST_ASSIGN_LE:
case AST_ASSIGN:
- while (children[0]->simplify(false, false, true, stage, -1, false) == true) { }
- while (children[1]->simplify(false, false, false, stage, -1, false) == true) { }
+ while (!children[0]->basic_prep && children[0]->simplify(false, false, true, stage, -1, false) == true) { }
+ while (!children[1]->basic_prep && children[1]->simplify(false, false, false, stage, -1, false) == true) { }
children[0]->detectSignWidth(backup_width_hint, backup_sign_hint);
children[1]->detectSignWidth(width_hint, sign_hint);
width_hint = std::max(width_hint, backup_width_hint);
@@ -247,11 +247,11 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
case AST_PARAMETER:
case AST_LOCALPARAM:
- while (children[0]->simplify(false, false, false, stage, -1, false) == true) { }
+ while (!children[0]->basic_prep && children[0]->simplify(false, false, false, stage, -1, false) == true) { }
children[0]->detectSignWidth(width_hint, sign_hint);
if (children.size() > 1) {
assert(children[1]->type == AST_RANGE);
- while (children[1]->simplify(false, false, false, stage, -1, false) == true) { }
+ while (!children[1]->basic_prep && children[1]->simplify(false, false, false, stage, -1, false) == true) { }
if (!children[1]->range_valid)
log_error("Non-constant width range on parameter decl at %s:%d.\n", filename.c_str(), linenum);
width_hint = std::max(width_hint, children[1]->range_left - children[1]->range_right + 1);
@@ -306,7 +306,7 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
width_hint = -1;
sign_hint = true;
for (auto child : children) {
- while (child->simplify(false, false, in_lvalue, stage, -1, false) == true) { }
+ while (!child->basic_prep && child->simplify(false, false, in_lvalue, stage, -1, false) == true) { }
child->detectSignWidthWorker(width_hint, sign_hint);
}
reset_width_after_children = true;
@@ -336,7 +336,7 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
if (detect_width_simple && width_hint < 0) {
for (auto child : children)
- while (child->simplify(false, false, in_lvalue, stage, -1, false) == true) { }
+ while (!child->basic_prep && child->simplify(false, false, in_lvalue, stage, -1, false) == true) { }
if (type == AST_REPLICATE)
while (children[0]->simplify(true, false, in_lvalue, stage, -1, false) == true) { }
detectSignWidth(width_hint, sign_hint);
@@ -1425,6 +1425,9 @@ apply_newNode:
did_something = true;
}
+ if (!did_something)
+ basic_prep = true;
+
return did_something;
}