opt_argmax pass#180
Conversation
Greptile SummaryThis PR adds
Confidence Score: 4/5The pass is safe to merge for typical use; the rewrite logic and fingerprint tests are thorough, and the non-matching cases are well-covered. The core detection and tree-emission logic is correct and guarded by a behavioral fingerprint over covering test vectors. Existing negative tests confirm the pass leaves non-matching designs untouched. The findings are all quality or documentation issues rather than incorrect transformations, and they do not affect correctness of the emitted netlist. passes/opt/opt_argmax.cc — the dead Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[OptArgmaxPass::execute] --> B[For each selected module]
B --> C[OptArgmaxWorker: build_indexes\nbuild bit_to_driver map\ncollect input_port_bits]
C --> D[run: enumerate output wires]
D --> E{out_width >= 2?}
E -- No --> D
E -- Yes --> F[get_cone: BFS from output\nup to max_cone_cells / max_leaf_bits]
F --> G{cone has $bmux?}
G -- No --> D
G -- Yes --> H[For each valid input wire\nwidth == 2^out_width]
H --> I[Collect index_buses / values_buses\nincl. split buses]
I --> J[check_candidate]
J --> K{width in range?\npower-of-two?\nindex_width matches?\nvalue_width in range?}
K -- No --> H
K -- Yes --> L{cone_has_required_shape?\nleaves_are_candidate_inputs?\nfind_anchor_driver?}
L -- No --> H
L -- Yes --> M[fingerprint via ConstEval\nover covering test vectors]
M --> N{Behavioral match?}
N -- No --> H
N -- Yes --> O[Record Candidate\nclaimed_outputs.insert out]
O --> D
D --> P[For each accepted Candidate]
P --> Q[emit_argmax:\nbmux leaves + balanced tree\nof not/lt/and/or/mux]
Q --> R[disconnect_old_output]
R --> S[module->connect out_wire to new output]
S --> T[run_pass: clean -purge]
Reviews (1): Last reviewed commit: "opt_argmax pass" | Re-trigger Greptile |
If your work is part of a larger effort, please discuss your general plans on Discourse first to align your vision with maintainers.
What are the reasons/motivation for this change?
Explain how this is achieved.
Make sure your change comes with tests. If not possible, share how a reviewer might evaluate it.
These template prompts can be deleted when you're done responding to them.