From: Clifford Wolf Date: Mon, 4 Nov 2013 15:46:14 +0000 (+0100) Subject: Fixed const folding of ternary operator X-Git-Tag: yosys-0.2.0~412 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d38c67f53d2284b0cb4e6ca2291b292442703c8a;p=yosys.git Fixed const folding of ternary operator --- diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index cc65658c8..643855d08 100644 --- a/frontends/ast/simplify.cc +++ b/frontends/ast/simplify.cc @@ -1033,10 +1033,11 @@ skip_dynamic_range_lvalue_expansion:; break; case AST_TERNARY: if (children[0]->type == AST_CONSTANT) { - if (children[0]->integer) - newNode = children[1]->clone(); - else - newNode = children[2]->clone(); + AstNode *choice = children[children[0]->integer ? 1 : 2]; + if (choice->type == AST_CONSTANT) { + RTLIL::Const y = choice->bitsAsConst(width_hint, sign_hint); + newNode = mkconst_bits(y.bits, sign_hint); + } } break; case AST_CONCAT: