summaryrefslogtreecommitdiff
path: root/frontends/ast
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2013-11-04 16:46:14 +0100
committerClifford Wolf <clifford@clifford.at>2013-11-04 16:46:14 +0100
commitd38c67f53d2284b0cb4e6ca2291b292442703c8a (patch)
tree2787fce5592e99de9727ad44d52425a884464f15 /frontends/ast
parent8d226da694ce5822a657ebbbed4a75406464b865 (diff)
Fixed const folding of ternary operator
Diffstat (limited to 'frontends/ast')
-rw-r--r--frontends/ast/simplify.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc
index cc65658c..643855d0 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: