Skip to content

Conversation

@uenoku
Copy link
Member

@uenoku uenoku commented Aug 30, 2025

This commit refactors the cut rewriter and implements correct priority sort metric for depth. Previously depth of a cut represents a logic depth within a cut but this is not correct. What the original paper (ICCAD 2007) proposed was to use arrival time of cut outputs instead.

For that this commit changes to perform cut matching for each cut, and use worst arrival time as a priority of cuts.

LUT6 depth for 16-bit multiplier improved from 17 to 7, which is on per with Yosys/ABC.

This commit refactors the cut rewriter and implements correct priority sort.
Previously `depth` of a cut represents a logic depth *within* a cut but
this is not correct. What the original paper (ICCAD 2007) proposed was to use
arrival time of cut outputs instead.

For tha this commit changes to perform cut matchings for each cut, and use
worst arrival time as a priority of cuts.

LUT6 depth for 16-bit multiplexier improved from 17 to 7, which is on per with
Yosys/ABC.
@uenoku uenoku force-pushed the dev/hidetou/cut-improvement branch from 72a193c to 08c4d99 Compare August 30, 2025 21:41
@uenoku uenoku requested a review from cowardsa September 1, 2025 08:33
Copy link
Contributor

@cowardsa cowardsa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - only comment on slightly improving documentation for heuristics chosen - perhaps this could also be reflected in dialect or synthesis documentation to make it clear what features are implemented and where the ideas come from?

Comment on lines 610 to 613
compareDelayAndArea(options.strategy, currentMatch->getArea(),
currentMatch->getArrivalTimes(),
bestCut->getMatchedPattern()->getArea(),
bestCut->getMatchedPattern()->getArrivalTimes())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the sorting criteria used above identical to the compareDelayAndArea?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point! I modified the sorting function to use compareDelayAndArea, and change the second loop just to return the first matched one.

Comment on lines 990 to 992
auto resultNumber = cast<mlir::OpResult>(input);
inputArrivalTimes.push_back(
matchedPattern->getArrivalTime(resultNumber.getResultNumber()));
matchedPattern.getArrivalTime(resultNumber.getResultNumber()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: mixture of result and input is a bit confusing here?

@uenoku uenoku force-pushed the dev/hidetou/cut-improvement branch from 80981ee to 79ae9d7 Compare September 2, 2025 03:51
@uenoku uenoku force-pushed the dev/hidetou/cut-improvement branch from 79ae9d7 to a242f39 Compare September 2, 2025 04:01
@uenoku
Copy link
Member Author

uenoku commented Sep 2, 2025

perhaps this could also be reflected in dialect or synthesis documentation to make it clear what features are implemented and where the ideas come from

Great point, I'll write down a rational document for Synth dialect and cut rewriter in a follow up.

@uenoku uenoku merged commit f7cbe28 into main Sep 2, 2025
6 checks passed
@uenoku uenoku deleted the dev/hidetou/cut-improvement branch September 2, 2025 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants