summaryrefslogtreecommitdiff
path: root/chapter09/src/main
Commit message (Collapse)AuthorAgeFilesLines
* Major overhaul debug printingCliff Click2026-09-173-132/+363
|
* Fix stale copy-pasted comment on BoolNode's phiCon call (#249)Symious2026-09-091-3/+4
| | | | | | | | | | | | | | | | | | The three comment lines above `AddNode.phiCon(this, ...)` in BoolNode were copy-pasted from MulNode and never adapted: they use `*` as the operator and describe the rotated shape `(x * (phi cons)) * con`. For BoolNode neither is right. The operator is a compare, and in chapters 6-9 `rotate` is hard-coded `false`, so the rotated shape is never matched; the shapes actually handled are `(phi cons) cmp con` and `(phi cons) cmp (phi cons)`. Reword the comment accordingly, and in chapters 6-9 add a line noting why rotate is off. Chapters 10-25 pass `this instanceof EQ`, so no such claim is made there. Comment-only change; no code is touched. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
* Backport renaming of `Type::_print()` in Chapter13 to earlier chapters (#244)Hsiang-Ying Fu2026-07-035-7/+7
|
* Move `addUse()` return statement to `keep()` (#243)Hsiang-Ying Fu2026-07-031-2/+2
|
* Cleanup (#162)RobertObkircher2025-02-161-1/+1
| | | | | | | | | * remove unused method lazyFRef * remove unused method copyF(Node, Node) * make TypeMemPtr constants final * make ConstantNode value final
* remove peephole from ProjNode::idealize that is already handled by computeRobert Obkircher2024-09-161-6/+2
|
* move x-x check up frontCliff Click2024-09-131-3/+4
|
* x-x==0Cliff Click2024-09-132-5/+9
| | | | | | Move x-x==0 to compute. Add x/1 ==> x All chapters
* Backport empty statement fixCliff Click2024-09-071-0/+1
| | | | | Split Ch13 tests from Chapter12Test.java Handle forward refs never defined.
* Fix grammar and forward-port minor changes (#91)Thalia Archibald2024-07-011-2/+1
| | | | | | | | | | | | | | | * Backport test exception handling to chapter 1 * Add unary ! to chapter 10 and 11 grammars * Lex { } ! as punctuation * Forward-port format whitespace * Forward-port test organization * Forward-port replace build-graphs.sh with Makefile * Add chapter title to chapter 11
* Backport tests (#87)Thalia Archibald2024-06-211-3/+7
| | | | | | | | | | | | | | | | | * Fix unexpected number parse errors * Add chapter titles * Split test files by chapter * Backport rename Fuzzer08Test to FuzzerWrap * Replace graph build scripts with Makefile * Backport Chapter05Test.testRegress1 * Backport require space after 'return' * Backport check EOF after return statement
* Format whitespace (#86)Thalia Archibald2024-06-2127-287/+287
| | | | | | | | | * Trim trailing whitespace * Ensure final new lines * Convert line endings from CRLF to LF * Replace tabs with spaces
* Chapter 9 (#66)Dibyendu Majumdar2024-03-0328-0/+3650
* chapter9 * merge fixes to chapter8 * Ch 9 notes * Ch 9 work Add a Iterate phase, after parsing. Add a Worklist with fast dup removal & rand pull. Add a Node.iter() call which returns progress or null. Peephole calls it. Iter() also asserts that Types make monotonic progress. Intern all types, so we can do a cheap/easy "isa" test. * GVN * rename temporarily * Apply Cliff's worklist changes * Apply Cliff's GVN changes * Revert "GVN" This reverts commit 9dc6db1cac7e40de4a58333cbc3c9c3e7c088e6f. * Revert "Ch 9 work" This reverts commit df5b74e6c017a4f237a5d1a550a83b40a7928876. * Fix 3-1+2 Was computing as 3-(1+2) == 0, not 4 as expected. Add tests. Unlock in swap12. * Missed some cut-n-paste changes * Break up the test file per-chapter * Fix keep-alive while looping expressions Must "hook" LHS prior to calling peepholes * Ch9 Region optimization Bug fix, GVN hits 2 inProgress Loops Bug fix lifetime tracking when parsing dead code Bug fix debug find call GraphViz post-iterate * Readme overhaul Progress on Ch 9 readme * Fix bugs hashcode Was relying on label() hashCode for Phi, Proj; since this is debug-only cannot be relied on. Proj relies on _idx field, Phi needs a !inProgress check. * Constant nodes print "#" before con * Add a farther neighbor check Peeps that check more than the nearest neighbor register a dependency on the Node that failed them. Should that Node later change, the peep root is put back on the worklist and revisited. * Fix addDeps assert Unwind golden test print, print smarter. Unlock edges in subsume * Update README * shuffle adddeps forward one its needed again shortly in another test, so just cover it now * Fix fuzzer bugs Peep x+(-y) to x-y Handle TOP inputs; didn't think it could happen before running an optimistic pass, but fuzzer proved me wrong. Deleting an input can recursively delete the self-node. When checking the compute() type assert, delay setting _type so the method can just be re-run in the debugger. Missing addDep in Phi Parser mis-handling stacked operators like "1+-2" or "1==!=<=<>=>2" Make Work list deterministic between tests. * Update fuzzer to run iterate (#62) * Update fuzzer to run iterate * Work seed is now reset by reset * A few more fuzzer tests Set _type in iter() even later, better debugging. Handle dead active scopes in visiualizer. Region ideal honors Loop invariants; finish Region ideal for single input; inProgress check is a little tighter. Type.isConstant is true strictly for lattice centerline constants. Clean up TypeInteger. ideaj warning removal * Fix all fuzzer bugs iter() does not call peep(), instead peep() is self-recursive. This allows Iterate() to call iter(), and not get into arbitrary recursive peep() changes that do not track on the worklist. Div, Minus, If all monotonic. Catch a bunch of progress issues. Robustify IRPrinter and Iterate and Region ideal * Reducer could run into an infinite loop (#63) * Write up how the Evaluator works (#64) * Write up how the Evaluator works * Some small improvements and a slightly better wrap up. * Series of fuzzer bugs. Fix monotonicity for all data nodes. Generic compute intercept for data nodes, check all inputs for TOP/BOTTOM, and again for IntDataNodes. Fix general progress bug allow high Types as constants. Fix progress Region 1-input has obvious idom. Make shortcut for fuzzer; renames Fuzzer to not have "Test" in the class name. Fix invert comment in TypeInteger * All fuzzer tests pass Turn off expensive assert accidentally turned on CSE needs to join types. Add a type join. Missing dep in Phi * More README * Hacking alternative way to fix the type compute * Node is no longer IntSupplier Renamed Work to WorkList Renamed Iterate to IterOptim Renamed Node.iter() to Node.peepholeOpt() WorkList expects elements to be of Node * Add an example of GVN * Rename the method depsClear to moveDepsToWorklist - to better capture what it actually does. * Add a second example of GVN benefits * Fix typo * Add example of worklist opt * Prepare to allow alternative post parse worklist opt * Alternative WorkList opt that has following differences: 1. It does not require dependencies between nodes 2. It does not require calls from inside the Node class, and therefore runs totally independently as a post parse step. 3. It is simple * Alternative WorkList opt that has following differences: 1. It does not require dependencies between nodes 2. It does not require calls from inside the Node class, and therefore runs totally independently as a post parse step. 3. It is simple * The RPO list was incomplete as it only identified the subgraph accessible from the STOP node. * Fix iter count * Add test suggested by Xmilia * Fix bug where after the region is peeped the phis get consistent number of inputs * Fix bug where after the region is peeped the phis get consistent number of inputs * Dump out stats on how many nodes we peepd during the post parse iterative opt. * Make it easy to switch the IterOpt * Use deps based worklist by default * Sharper worklist add * Copy across Cliff's changes * Merge changes to Iterate * Revert failing change * Update readme * Add comments / update docs to explain the patterns where we call addDep(). * As before, unconditionally made dep a dependent of region. * Fix a lot of missing dep issues Rename IterOptim -> IterPeeps Some grammar changes in comments & readme * Bump up fuzzer limits, more testing Missing dep in idom calc in IfNode. Missed idom cache clear on Region edit. * Remove RPO based peeps O(n^2) behavior * Minor updates README * fix compile bug --------- Co-authored-by: Cliff Click <cliffc@acm.org> Co-authored-by: XmiliaH <45106915+XmiliaH@users.noreply.github.com> Co-authored-by: Darrick Wiebe <darrickw@untether.ai>