clash-lang / clash-compiler

Haskell to VHDL/Verilog/SystemVerilog compiler
https://clash-lang.org/
Other
1.42k stars 151 forks source link

The power of `Index` #2813

Open kleinreact opened 1 day ago

kleinreact commented 1 day ago

The following code

module Top where

import Clash.Prelude

topEntity :: HiddenClockResetEnable System => Signal System (Index (2 ^ 61))
topEntity = pure 0

causes clash from master (currently 3b755b9) to get stuck and to eat up all my 64G of memory after about 15 minutes. Just run

cabal run -- clash-ghc:clash Top.hs  --verilog

from within the repository for reproduction. There seems to be an exponential rise in compile time that is directly related to the chosen exponent. Here are some compile times, produced via replacing the 61 in the code above with the given values.

Exponent Time (s)
24 0.698
25 0.754
26 0.890
27 1.204
28 1.763
29 3.191
30 6.050
31 11.397
32 25.777

Everything works, if I compile the file with my system clash tough, which still is at v1.8.1. I tested the behavior with GHC 9.6.4 and 9.8.2.

kleinreact commented 1 day ago

It looks like the issue was introduced by #2689, as compilation times are more or less constant before that PR got merged.