Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(hugr-passes)!: Rewrite constant_fold_pass using dataflow framewo…
…rk (#1603) New transformation roughly parallels the old constant-folding code + dead-code-elimination (eliminating cases from conditionals/tail-loops and transforming into DFGs, left for another PR). Should be significantly more powerful, and flexible - e.g. the old code broke if `OpType::const_fold` returned only some outputs from a leaf op. **All the existing constant-folding tests pass!** 😀 🚀, plus at least one that didn't just fail-to-optimize, but panicked - or, in release mode, potentially produced an invalid hugr - [see comment](https://github.com/CQCL/hugr/pull/1603/files#r1823146181). closes #1322 BREAKING CHANGE: ConstantFoldPass is no longer UnwindSafe. BREAKING CHANGE: ConstantFoldPass is no longer RefUnwindSafe. BREAKING CHANGE: ConstantFoldPass no longer derives Copy. BREAKING CHANGE: fold_leaf_op function removed. BREAKING CHANGE: find_consts function removed. BREAKING CHANGE: ConstantFoldPass::new function removed. Instead use ConstantFoldPass::default. BREAKING CHANGE: Variant `ConstFoldError::SimpleReplacementError` was removed. --------- Co-authored-by: Douglas Wilson <[email protected]> Co-authored-by: Douglas Wilson <[email protected]> Co-authored-by: Craig Roy <[email protected]>
- Loading branch information