Skip to content

Commit ae2ed5e

Browse files
committed
Fix wreduce speed more
1 parent f7dbfcb commit ae2ed5e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

kernel/modtools.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ struct ModIndex : public RTLIL::Monitor
7878
SigMap sigmap;
7979
RTLIL::Module *module;
8080
std::map<RTLIL::SigBit, SigBitInfo> database;
81+
int reload_counter;
8182
int auto_reload_counter;
8283
bool auto_reload_module;
8384

@@ -106,6 +107,10 @@ struct ModIndex : public RTLIL::Monitor
106107

107108
void reload_module(bool reset_sigmap = true)
108109
{
110+
reload_counter++;
111+
if (reload_counter % 10 == 0)
112+
log_warning("ModIndex::reload_module() called %d times.\n", reload_counter);
113+
109114
if (reset_sigmap) {
110115
sigmap.clear();
111116
sigmap.set(module);
@@ -231,6 +236,7 @@ struct ModIndex : public RTLIL::Monitor
231236

232237
ModIndex(RTLIL::Module *_m) : sigmap(_m), module(_m)
233238
{
239+
reload_counter = 0;
234240
auto_reload_counter = 0;
235241
auto_reload_module = true;
236242
module->monitors.insert(this);

passes/opt/wreduce.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ struct WreduceWorker
7878
for (int i = GetSize(sig_y)-1; i >= 0; i--)
7979
{
8080
auto info = mi.query(sig_y[i]);
81+
if (info == nullptr)
82+
return;
8183
if (!info->is_output && GetSize(info->ports) <= 1 && !keep_bits.count(mi.sigmap(sig_y[i]))) {
8284
bits_removed.push_back(State::Sx);
8385
continue;
@@ -408,6 +410,8 @@ struct WreduceWorker
408410
break;
409411

410412
auto info = mi.query(bit);
413+
if (info == nullptr)
414+
return;
411415
if (info->is_output || GetSize(info->ports) > 1)
412416
break;
413417

@@ -566,6 +570,10 @@ struct WreduceWorker
566570
for (int i = GetSize(w)-1; i >= 0; i--) {
567571
SigBit bit(w, i);
568572
auto info = mi.query(bit);
573+
if (info == nullptr) {
574+
unused_top_bits = 0;
575+
break;
576+
}
569577
if (info && (info->is_input || info->is_output || GetSize(info->ports) > 0))
570578
break;
571579
unused_top_bits++;

0 commit comments

Comments
 (0)