Skip to content

🐛 Harden MLIR constant folding - #2290

Merged
burgholzer merged 2 commits into
mainfrom
codex/2255-constant-folding-contracts
Sep 1, 2026
Merged

🐛 Harden MLIR constant folding#2290
burgholzer merged 2 commits into
mainfrom
codex/2255-constant-folding-contracts

Conversation

@simon1hofmann

@simon1hofmann simon1hofmann commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Description

Extends the shared MQT constant-folding helper found during the #2255 MLIR contract audit.

  • keep the existing memoized recursive evaluation of pure SSA expression DAGs;
  • recognize dialect-defined constant-like operations through MLIR's existing m_Constant matcher instead of accepting only arith.constant;
  • add a focused index.constant regression.

Following review, this drops the speculative iterative worklist and synthetic 10,000-operation depth contract. The PR is now limited to the demonstrated constant-like folding gap.

This is one focused replacement for draft PR #2287. It addresses part of #2255 without closing the umbrella audit issue.

Validation

  • focused MQT utilities target build — passed
  • mqt-core-mlir-unittests-mqt-utils --gtest_brief=1 — 21/21 passed
  • commit hooks, including clang-format — passed
  • git diff --check — passed

Checklist

  • The pull request only contains commits that are focused and relevant to this change.
  • I have added appropriate tests that cover the new/changed functionality.
  • I have updated the documentation to reflect these changes.
  • I have added entries to the changelog for any noteworthy additions, changes, fixes, or removals.
  • I have added migration instructions to the upgrade guide (if needed).
  • The changes follow the project's style guidelines and introduce no new warnings.
  • The changes are fully tested and pass the CI checks.
  • I have reviewed my own code changes.

If PR contains AI-assisted content:

  • Any agent that created, edited, or submitted GitHub content was explicitly authorized for that scope, as required by our AI Usage Guidelines.
  • Every agent-authored or agent-edited public text body begins with the visible disclosure 🤖 *AI text below* 🤖 (titles are exempt).
  • I have disclosed AI assistance in the PR description.
  • I confirm that I have personally reviewed and understood all AI-generated content, and accept full responsibility for it.

AI assistance disclosure: Codex narrowed this focused change in response to review feedback, validated it, and updated this description.

Assisted-by: GPT-5.6 Sol via Codex
@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@simon1hofmann simon1hofmann self-assigned this Aug 31, 2026
@simon1hofmann simon1hofmann added c++ Anything related to C++ code code quality Code quality improvements fix Fix for something that isn't working MLIR Anything related to MLIR skip-changelog Changes that do not need to show up in the changelog labels Aug 31, 2026
@burgholzer burgholzer added this to the v4.0.0 - IEEE Quantum Week milestone Sep 1, 2026

@burgholzer burgholzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one small request, otherwise this one looks pretty clean to me.

Comment thread mlir/lib/Dialect/MQT/Utils/ConstantFolding.cpp Outdated
Restore the memoized recursive fold implementation and remove the synthetic deep-expression regression. Keep only the constant-like operation support with its focused test.

Assisted-by: GPT-5.6 via Codex
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Important

Approval pending

CodeRabbit has no unresolved comments, but it has not reviewed the latest commit.

Use the checkbox below to review the latest commit. CodeRabbit will approve the changes if it finds no blocking issues.

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@burgholzer burgholzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this makes more sense to me 👍🏼 let's get it in this way!

@burgholzer
burgholzer enabled auto-merge (squash) September 1, 2026 11:45
@burgholzer
burgholzer merged commit 363bf15 into main Sep 1, 2026
26 checks passed
@burgholzer
burgholzer deleted the codex/2255-constant-folding-contracts branch September 1, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Anything related to C++ code code quality Code quality improvements fix Fix for something that isn't working MLIR Anything related to MLIR skip-changelog Changes that do not need to show up in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants