Skip to content

test: extend C-vs-MLIR differential parity suite (+21 cases, records the gap boundary) - #875

Merged
godofecht merged 1 commit into
mainfrom
test/mlir-c-parity-suite
Sep 10, 2026
Merged

godofecht merged 1 commit into
mainfrom
test/mlir-c-parity-suite

Conversation

@godofecht

Copy link
Copy Markdown
Contributor

Addresses the "MLIR parity is under-verified" gap: the existing test_backend_parity.py was strong (48 cases) but the differential coverage stopped short of several feature categories, and there was no explicit record of where the MLIR backend actually falls short.

What this adds

tests/unit/test_backend_parity_extended.py — 21 cases, all verified to agree across the C backend and the MLIR JIT on a machine with the real toolchain (mlir-opt / mlir-translate / clang):

  • 16 exit-code parity cases: f64 add/mul/div, i64 and u32 arithmetic, integer division and modulo, bitwise (& | ^) and shift (<< >>) operators, the full comparison set, capturing closures, nested struct-containing-array, mutual recursion, boolean not, break inside a for loop, and a for loop nested inside a parallel for.
  • 3 stdout parity cases: effect handler (direct), effect op returning a value, and println.
  • 2 boundary cases: string runtime helpers (len, concatenation) that the C backend compiles and runs but the MLIR JIT cannot lower.

The boundary is the point

test_mlir_known_gap_still_open asserts the C backend handles those string cases and the MLIR JIT does not. If MLIR gains support, that test fails loudly — the signal to promote the case into a parity set and update the maturity doc. This turns "MLIR is PARTIAL, somehow" into a pinned, self-maintaining frontier.

Honest finding

Probing to build this showed the MLIR backend is more complete than the maturity doc's "PARTIAL" implied: effects (including value-returning ops), f64, i64/u32, bitwise/shift, capturing closures, and loop-in-parallel nesting all reach parity. The genuine remaining gap in these probes was string runtime helpers. The maturity doc's differential-tests row is updated to reflect the ~69 combined cases and the recorded gap.

Combined suite (test_backend_parity.py + _extended): 69 passed locally. All cases skip when the MLIR toolchain is absent, matching the existing needs_mlir guard.

…dary)

Adds tests/unit/test_backend_parity_extended.py covering categories the
existing suite missed: f64/i64/u32 arithmetic, integer div/mod, bitwise and
shift operators, comparison operators, capturing closures, mutual recursion,
nested struct+array aggregates, effect handlers (direct and value-returning),
and for-loop-inside-parallel nesting. 16 exit-code + 3 stdout cases, all
verified identical across both backends with the real MLIR toolchain.

Also records the current parity boundary explicitly: string runtime helpers
(len, concatenation) compile+run on the C backend but the MLIR JIT cannot
lower them. test_mlir_known_gap_still_open pins this and fails loudly if MLIR
gains support, prompting a promotion + maturity-doc update.

Updates docs/project/maturity.md differential-tests row to reflect the ~69
combined cases and the recorded gap.

Co-Authored-By: Claude Fable 5 <[email protected]>
@godofecht
godofecht merged commit cc1382d into main Sep 10, 2026
23 of 25 checks passed
@godofecht
godofecht deleted the test/mlir-c-parity-suite branch October 1, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant