Skip to content

Commit

Permalink
[FIRRTL] Dedup: record less indices when hashing (#7816)
Browse files Browse the repository at this point in the history
We map operations to their index as they appear in the IR, so that we
can use the index when hashing their uses as operands and inner-symbol
references. We only need to bother assigning indices to operations which
actually have results or an inner-symbol.  Technically we can do a
little better, the result or symbol has to actually have a user, but we
we don't have many trivially dead expressions on our input.
  • Loading branch information
youngar authored Nov 14, 2024
1 parent bf43ca2 commit 215f373
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/Dialect/FIRRTL/Transforms/Dedup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,13 @@ struct StructuralHasher {

// NOLINTNEXTLINE(misc-no-recursion)
void update(Operation *op) {
record(op);
if (op->getNumResults())
record(op);
else if (auto innerSym = dyn_cast<hw::InnerSymbolOpInterface>(op))
if (auto attr = innerSym.getInnerSymAttr())
if (!attr.empty())
record(op);

update(op->getName());

// Hash the operands.
Expand Down

0 comments on commit 215f373

Please sign in to comment.