diff --git a/passes/techmap/alumacc.cc b/passes/techmap/alumacc.cc index 2a1fcb9f9..29ec094b4 100644 --- a/passes/techmap/alumacc.cc +++ b/passes/techmap/alumacc.cc @@ -380,7 +380,10 @@ struct AlumaccWorker alunode->c = C; alunode->y = n->y; - sig_alu[RTLIL::SigSig(A, B)].insert(alunode); + // only consider merging if the output is at least as wide as the inputs + if (max(GetSize(A), GetSize(B)) <= GetSize(n->y)) { + sig_alu[RTLIL::SigSig(A, B)].insert(alunode); + } delete_nodes.insert(n); next_macc:; } @@ -432,10 +435,6 @@ struct AlumaccWorker // comparators need subtraction return false; } - if (max(GetSize(cmp_A), GetSize(cmp_B)) > GetSize(node->y)) { - // must have at least as many output bits - return false; - } if (is_signed != node->is_signed) { if (GetSize(cmp_A) != GetSize(cmp_B)) { // mismatched input widths are problematic when mixing signedness