Skip to content

Commit 34ce691

Browse files
acl-cqcdoug-qcroyzor
authored
feat(hugr-passes)!: Rewrite constant_fold_pass using dataflow framework (#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 <douglas.wilson@quantinuum.com> Co-authored-by: Douglas Wilson <141026920+doug-q@users.noreply.github.com> Co-authored-by: Craig Roy <croyzor@users.noreply.github.com>
1 parent cb5d9ec commit 34ce691

File tree

6 files changed

+871
-198
lines changed

6 files changed

+871
-198
lines changed

hugr-passes/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ bench = false
1717

1818
[dependencies]
1919
hugr-core = { path = "../hugr-core", version = "0.13.3" }
20+
portgraph = { workspace = true }
2021
ascent = { version = "0.7.0" }
2122
itertools = { workspace = true }
2223
lazy_static = { workspace = true }

0 commit comments

Comments
 (0)