diff options
author | Clifford Wolf <clifford@clifford.at> | 2013-11-07 18:18:16 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2013-11-07 18:18:16 +0100 |
commit | 02f4f89fdba402a1fa74f2f88291f7e1a37db0f2 (patch) | |
tree | cea20ab261d5561d0be88b4d18de1d86bf5f236f /frontends/ast/simplify.cc | |
parent | 947bd9b96bb978e204275d6fbbc9ce9ff6eda28c (diff) | |
download | yosys-02f4f89fdba402a1fa74f2f88291f7e1a37db0f2.tar.gz yosys-02f4f89fdba402a1fa74f2f88291f7e1a37db0f2.tar.bz2 yosys-02f4f89fdba402a1fa74f2f88291f7e1a37db0f2.zip |
Disabled const folding of ternary op when select is undef
Diffstat (limited to 'frontends/ast/simplify.cc')
-rw-r--r-- | frontends/ast/simplify.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index 7712023c5..7b5ae064c 100644 --- a/frontends/ast/simplify.cc +++ b/frontends/ast/simplify.cc @@ -1058,8 +1058,20 @@ skip_dynamic_range_lvalue_expansion:; break; case AST_TERNARY: if (children[0]->type == AST_CONSTANT) { - AstNode *choice = children[children[0]->integer ? 1 : 2]; - if (choice->type == AST_CONSTANT) { + bool found_sure_true = false; + bool found_maybe_true = false; + for (auto &bit : children[0]->bits) { + if (bit == RTLIL::State::S1) + found_sure_true = true; + if (bit > RTLIL::State::S1) + found_maybe_true = true; + } + AstNode *choice = NULL; + if (found_sure_true) + choice = children[1]; + else if (!found_maybe_true) + choice = children[2]; + if (choice != NULL && choice->type == AST_CONSTANT) { RTLIL::Const y = choice->bitsAsConst(width_hint, sign_hint); newNode = mkconst_bits(y.bits, sign_hint); } |