Merge pull request #971 from larsclausen/arith-expr-type-fix-runtime

Avoid exponential execution time behavior in arith_expr_type()
This commit is contained in:
Stephen Williams 2023-07-13 19:38:21 -07:00 committed by GitHub
commit f2621d88c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -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;