alumacc: Move undersize check

Don't add undersized arithmetic to the pool of mergeable nodes (though a `wreduce` prior should make undersized output impossible).
This commit is contained in:
Krystine Sherwin 2026-07-29 13:25:36 +12:00
parent 2942aa76f5
commit c1450b54e4
No known key found for this signature in database
1 changed files with 4 additions and 5 deletions

View File

@ -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