Fixed/improved opt_const $eq/$ne/$eqx/$nex handling
authorClifford Wolf <clifford@clifford.at>
Fri, 27 Dec 2013 13:21:24 +0000 (14:21 +0100)
committerClifford Wolf <clifford@clifford.at>
Fri, 27 Dec 2013 13:21:24 +0000 (14:21 +0100)
passes/opt/opt_const.cc

index 30d85588cd307692ea4c7f0ab2b5093506492a5f..d84910ee188d126cd698d57cb55f5191e3f84393 100644 (file)
@@ -166,6 +166,8 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
                                        if (b.chunks[i].wire == NULL && b.chunks[i].data.bits[0] > RTLIL::State::S1)
                                                continue;
                                }
+                               if (a.chunks[i] == b.chunks[i])
+                                       continue;
                                new_a.append(a.chunks[i]);
                                new_b.append(b.chunks[i]);
                        }
@@ -177,7 +179,7 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
                                goto next_cell;
                        }
 
-                       if (new_a.width != a.width) {
+                       if (new_a.width < a.width || new_b.width < b.width) {
                                new_a.optimize();
                                new_b.optimize();
                                cell->connections["\\A"] = new_a;