Repository navigation
Conversation
grapentt
force-pushed
the
512-baseline-wrapper
branch
3 times, most recently
from
July 8, 2026 12:15
23fee41 to
8073761
Compare
grapentt
marked this pull request as ready for review
July 8, 2026 12:21
grapentt
marked this pull request as draft
July 8, 2026 12:24
grapentt
force-pushed
the
512-baseline-wrapper
branch
from
July 8, 2026 13:05
0c9c3c4 to
8073761
Compare
grapentt
force-pushed
the
512-baseline-wrapper
branch
from
July 12, 2026 21:41
2b247b0 to
85d0968
Compare
grapentt
force-pushed
the
512-baseline-wrapper
branch
from
July 18, 2026 20:31
85d0968 to
ce3556e
Compare
grapentt
force-pushed
the
512-baseline-wrapper
branch
from
July 18, 2026 22:46
9415eae to
8d8d5aa
Compare
grapentt
marked this pull request as ready for review
July 19, 2026 16:17
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Foundation for #512. This PR doesn't add any algebraic rewrites, it makes MLIR's purity traits and CSE apply to DaphneIR, so those rewrites can compose correctly later.
The four PRs:
ScalarConstantFoldableinterface and the algebraic-trait vocabulary; moving existing rewrites onto it and adding new trait-based rewrites.What changed
Attach
Pureto ~150 opsPureexpands toTraitList<[AlwaysSpeculatable, NoMemoryEffect]>. WithoutNoMemoryEffect, CSE'ssimplifyOperationbails out and the op is never a candidate for elimination. Annotated seven base classes inDaphneOps.td(aggregations, group-aggregations, outer-binary, bind, activation-forward, pool-forward, the five columnar bases) plus thirteen individual ops:SyrkOp,GemvOp,SolveOp,DiagMatrixOp,EigenOp,ReshapeOp,ReverseOp,OrderOp,SoftmaxOp,Conv2DForwardOp,TypeOfOp,SparsityOp,IsSymmetricOp.Retire the 5×CSE loop in
DaphneIrExecutor.cppThe columnar branch ran CSE five times behind a TODO that said "CSE seems to eliminate only one row of dead code at a time... how to apply CSE until a fixpoint?" The observation was real: CSE defers dead-op erasure to the end of its walk and never revisits an op, so a dead chain of length N needs N passes to fully collapse. It's now a single
createCSEPass(), because the canonicalizer that runs right before CSE already drives DCE to a fixpoint (its greedy driver erases dead ops immediately and re-queues their operands), so the dead chains are gone before CSE runs. Confirmed empirically: full suite byte-identical ati < 5vsi < 1, andnumDCE == 0on every CSE run.Seed CSE in
buildCodegenPipelineTwo nested-FuncOp CSE passes:
LinalgElementwiseOpFusionPass(fusion often exposes duplicate memref/tensor ops)Both sit behind
use_mlir_codegen/use_mlir_hybrid_codegen, so non-MLIR-codegen pipelines are untouched.Verification
daphne-opt --cseon IR with two identicaldaphne.sumAllcalls on the same operand deduplicates them (num-cse'd0 → 2). End-to-end,sum(X) + sum(X)withX = fill(1.0, 4, 3)shows twodaphne.sumAllunder--explain parsingand one under--explain parsing_simplified.test/codegen/purity_cse_syrk.mlirrunsdaphne-opt --cseon two identicalsyrkops and checks that only one survives. A case that depends on the new tag, since on the pre-Purebuild both survive and the test fails.Full suite via a small wrapper that filters two pre-existing aarch64-only crashes (#1011, #1012, neither of which reproduces on x86_64 CI): 2431 matched, 2318 passed, 113 failed. Byte-identical before and after this PR.
Out of scope
Kept impure by design:
IncRefOp/DecRefOp(ref counting; CSE must not delete them; seeDaphneIrExecutor.cpp:225-231),RandMatrixOp/SampleOp/NowOp(non-deterministic),VectorizedPipelineOp(regional effects, TODO atDaphneOps.td:1907). Also skipped:QrOp/SvdOp(no kernel or lowering yet) andEwAddOpCommutativerestoration (#449 / #351).On the commit range
This PR is stacked on #1010 (the kernel-compile OOM fix). #1010's branch lives on my fork and can't be a PR base upstream, so the first six commits here duplicate #1010's contents. Once #1010 merges I'll rebase and force-push; the duplicated commits drop out, leaving only the purity + CSE commits.
Refs #512.