mirror of
https://github.com/YosysHQ/yosys.git
synced 2026-09-05 19:36:55 +02:00
Problem: LoopRotatePass applies a transformation to each loop which has O(function size) cost due to invalidating some bookkeeping. CXXRTL output is one huge function with thousands of loops. Most of these loops are 1-trip but that doesn't help because loop elimination is after loop rotation. Fix is to add an `if` (with constexpr condition) for the common 1-word case, to cause the loop to be DCE'd long before LoopRotatePass. This does not seem to affect performance (at -O2) but reduces compile time for Hazard by around 7.5x. Do this for the worst offenders: trunc, zext, sext, rtrunc, rzext, which are used everywhere in slice and concat. Arguably an upstream LLVM bug but it has been present since v18 at least, so affects a lot of users.