Skip to content

Commit

Permalink
Merge pull request #971 from larsclausen/arith-expr-type-fix-runtime
Browse files Browse the repository at this point in the history
Avoid exponential execution time behavior in arith_expr_type()
  • Loading branch information
steveicarus authored Jul 14, 2023
2 parents fdb9465 + 26d1c72 commit f2621d8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions net_expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,15 @@ NetEBAdd::~NetEBAdd()

static ivl_variable_type_t arith_expr_type(const NetExpr *l, const NetExpr *r)
{
if (l->expr_type() == IVL_VT_REAL ||
r->expr_type() == IVL_VT_REAL)
auto l_expr_type = l->expr_type();
auto r_expr_type = r->expr_type();

if (l_expr_type == IVL_VT_REAL ||
r_expr_type == IVL_VT_REAL)
return IVL_VT_REAL;

if (l->expr_type() == IVL_VT_LOGIC ||
r->expr_type() == IVL_VT_LOGIC)
if (l_expr_type == IVL_VT_LOGIC ||
r_expr_type == IVL_VT_LOGIC)
return IVL_VT_LOGIC;

return IVL_VT_BOOL;
Expand Down

0 comments on commit f2621d8

Please sign in to comment.