Skip to content

Add lutresyn for post-mapping LUT-count reduction - #618

Open
flyingfoxyy wants to merge 3 commits into
berkeley-abc:masterfrom
flyingfoxyy:lutresyn
Open

flyingfoxyy wants to merge 3 commits into
berkeley-abc:masterfrom
flyingfoxyy:lutresyn

Conversation

@flyingfoxyy

@flyingfoxyy flyingfoxyy commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What this adds

lutresyn is a post-mapping LUT-count optimizer for LUT-mapped networks. For each LUT root it

  1. collects the fanout-free cone of the root (-Q allows absorbing a bounded number of nodes whose fanouts leave the cone),
  2. computes the function of the cone over its leaves,
  3. enumerates bounded alternative cuts of the cone,
  4. tries to re-implement the cut function with 1..M LUTs of the same size (one LUT, prefix + suffix, or two prefixes + suffix),
  5. commits the rewrite only if the LUT count strictly decreases and the level increase stays within -L.
usage: lutresyn [-KRLMQ num] [-vh]
         reduces the LUT count by re-implementing fanout-free cones with up to M LUTs
    -K num : the max LUT size [default = 6]
    -R num : the number of passes [default = 1]
    -L num : the allowed increase of the logic level [default = 0]
    -M num : the max number of LUTs produced per cone, 1..3 [default = 2]
    -Q num : the max number of absorbed nodes with fanouts outside the MFFC [default = 0]
    -v     : toggles printing verbose information [default = no]
    -h     : print the command usage

The command is a post-mapping optimizer complementary to lutpack: it keeps the LUT size fixed, performs a bounded resynthesis of each cone, and does not require a LUT library.

Verification

  • New regression script test/lutresyn.sh covers five scenarios: the -M bound, the strict LUT-count reduction rule, the global -L level budget, alternative cuts being accepted, and -Q absorption. It is wired into test/CMakeLists.txt and both POSIX CI workflows.
  • Every benchmark result below passed cec -n (Networks are equivalent).

Benchmark comparison with lutpack

Flow: read X.aig; st; resyn; resyn2; if -K 6; <command>; cec -n. lutpack was run with a 6-input LUT library installed via read_lut (with ABC's default 4-input library it warns and is effectively inert on 6-LUT networks). Time is the transform stage only, measured with time -p (eight single-threaded benchmarks run concurrently on a 16-core machine, under identical conditions for every command); the baseline (st; resyn; resyn2; if -K 6) is excluded from the reported time.

51 complete cases from the standard EPFL/ISCAS/ITC'99 AIG benchmarks:

  • lutpack -S 3: 150,430 LUTs vs 155,982 baseline (-5,552, -3.56%; geomean -3.64%), 165.64 s total.
  • lutresyn -R 3: 152,533 LUTs vs 155,982 baseline (-3,449, -2.21%; geomean -2.66%), 2.61 s total.

Key result: lutresyn is ~37x faster than lutpack on these benchmarks (geomean of per-circuit transform-time ratios; total-time ratio 63x), while the geomean LUT-count difference between the two is only ~1% per circuit. lutresyn is faster on all 51 circuits. lutpack's remaining LUT-count advantage is concentrated in a few memory-like designs (wb_conmax -992, mem_ctrl -577, DMA -366), while lutresyn does better on aes_core (-151), log2 (-126), div (-94), usb_funct (-33), sqrt (-28), and sin (-21).

Full 51-case table (LUT count / level, and transform time)
circuit baseline lutpack -S3 t (s) lutresyn -R3 t (s)
c17 2/1 2/1 0.05 2/1 0.00
c432 52/8 50/8 0.07 52/8 0.00
int2float 47/3 40/3 0.10 36/3 0.01
ctrl 29/2 29/2 0.06 29/2 0.00
c1908 63/5 63/5 0.06 63/5 0.00
c880 81/6 80/6 0.09 75/6 0.01
c499 58/4 58/4 0.04 58/4 0.00
ss_pcm 104/2 104/2 0.04 104/2 0.00
usb_phy 135/2 133/2 0.04 134/2 0.00
c1355 58/4 58/4 0.03 58/4 0.00
router 76/6 67/6 0.05 72/6 0.00
cavlc 118/4 110/4 0.32 99/4 0.02
sasc 153/2 152/2 0.04 152/2 0.00
c3540 236/7 226/7 0.25 229/7 0.01
simple_spi 208/3 207/3 0.03 208/3 0.00
priority 178/26 126/26 0.07 166/23 0.00
c2670 130/5 125/5 0.09 129/5 0.00
iwls05_i2c 259/4 249/4 0.07 254/4 0.01
c6288 521/16 521/16 0.04 519/16 0.00
dec 287/2 287/2 0.03 287/2 0.00
c7552 395/6 380/6 0.93 390/6 0.01
adder 257/51 257/51 0.03 257/51 0.00
i2c 316/4 299/4 0.11 305/4 0.02
c5315 280/6 275/6 0.27 273/6 0.01
systemcdes 595/5 594/5 0.04 593/5 0.00
spi 888/7 789/7 1.00 842/7 0.02
bar 512/4 512/4 0.03 512/4 0.00
des_area 714/6 714/6 0.05 714/6 0.00
sin 1477/36 1472/36 2.06 1451/36 0.01
max 793/39 791/39 2.29 791/39 0.01
tv80 2103/11 1936/11 2.21 2005/11 0.07
systemcaes 1970/8 1880/8 1.85 1958/8 0.03
arbiter 2722/18 2722/18 0.12 2722/18 0.01
voter 1736/13 1725/13 0.15 1726/13 0.01
square 3949/50 3948/50 0.09 3945/50 0.01
iwls05_mem_ctrl 2816/8 2741/8 0.49 2750/8 0.04
ac97_ctrl 2909/3 2890/3 0.17 2889/3 0.01
usb_funct 3448/6 3405/6 0.62 3372/6 0.04
sqrt 4645/1017 4639/1017 3.72 4611/1017 0.03
aes_core 3741/5 3392/5 1.05 3241/5 0.38
multiplier 5922/53 5921/53 0.14 5920/53 0.03
DMA 6239/6 5728/6 5.36 6094/6 0.09
log2 8077/71 7994/71 8.44 7868/71 0.10
pci_bridge32 5354/7 5108/7 1.31 5255/7 0.07
wb_conmax 11949/6 10512/6 30.88 11504/6 0.26
DSP 10965/13 10675/13 6.29 10763/13 0.17
div 9931/856 9867/856 5.01 9773/856 0.05
mem_ctrl 11747/25 10217/25 80.89 10794/25 0.69
des_perf 12796/3 12796/3 0.38 12796/3 0.02
RISC 15851/9 15637/9 3.02 15664/9 0.18
ethernet 18090/7 17927/7 5.08 18029/7 0.18

Seven large industrial designs are not included in the table because equivalence checking or the run did not complete within the time cap: on hyp (44,338 -> 44,320 with lutpack, 44,303 with lutresyn), netcard (168,728 -> 165,775 / 166,177), and leon3_opt (367,392 -> 366,582 / 366,424) the transforms finished but cec -n did not; leon3, leon2, leon3mp, and vga_lcd did not complete.

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.

1 participant