Repository navigation
feat(topic28): extend RISC-V instruction selection and f64 support - #85
Merged
jizhenjun merged 17 commits intoOct 24, 2026
Merged
Conversation
🤖 AI Code Review
Full per-file results and batch artifacts Files without a review
|
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The design contains unresolved type-validation and floating-point spill/reload issues, plus configuration and ordering ambiguities.
Review effort: Lite
Findings: None
What changed in this PR
Adds a technical design for Topic 28 instruction selection and links it from the topic page.
Changes:
- Defines typed IR, integer/F/D floating-point lowering, register allocation, ABI, and constant folding.
- Adds CLI integration, testing, acceptance criteria, and phased implementation planning.
- Links the new design document from the topic page.
| File | Summary |
|---|---|
docs/topics/28-扩展指令选择/28-扩展指令选择.md |
Adds the design document link. |
docs/topics/28-扩展指令选择/28-扩展指令选择-设计文档.md |
Adds the comprehensive instruction-selection design. Findings: unknown ONNX types must fail instead of silently becoming FLOAT32 (critical, 1 vote); FPR spill/reload needs value-width/type propagation (moderate, 1 vote); rounding_mode requires validation (moderate, 1 vote); candidate priority direction should be defined (nit, 1 vote). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
Author
|
@copilot code review |
Add independent-function regressions and expand LLVM integer input rejection tests, recording before/after validation in the review report.
Decode constant storage bits consistently at load and operand boundaries, preserving instruction-only encodings within each function. Add bit-level regression tests and document before/after validation.
Explain the findings and fixes in plain language, mark all four issues as resolved, and retain reproduction examples and validation results.
ForsakenDelusion
force-pushed
the
docs/topic28-design
branch
2 times, most recently
from
October 19, 2026 17:24
7217607 to
a4e37ba
Compare
Resolve IR, ONNX frontend, optimizer, and CI conflicts while preserving both checked tensor semantics and RV32 scalar behavior. Keep floating-point encodings consistent across execution, folding, and Qwen audits. Validation: 6519 tests passed and 9 skipped in the core regression run; 20 W3 subgraph tests passed separately. Added 12 merge integration regressions. Optional Torch exporter validation requires the upstream pinned environment.
Unknown ONNX output dimensions were recorded as exact zero-sized tensor shapes after the merge, causing valid Qwen Reshape results to fail runtime checks. Preserve unknown tensor outputs without those scalar rejection sentinels, while retaining real zero dimensions and scalar backend checks. Initialize DSL benchmark accumulators with syntax shared by the baseline parser, and propagate simulator errors even without an expected-output file. Materialize loop bounds at their use, select signed immediate comparisons, and retain greedy mappings only across unique adjacent fallthrough edges. This removes redundant spills/reloads without relaxing Topic 06 cost gates. Add regression coverage for dynamic shapes, genuine zero extents, benchmark failure reporting, signed comparison boundaries and branch joins. Validation: 6623 pytest tests passed, 2 platform/tool skips; 113 Qwen probe regressions passed; fresh two-layer Qwen export passed all 7 input cases, 29 checkpoints and 6 invariants. DSL corpus: 23/23. Topic 06 required gates: activation 4/4, elementwise 5/5, loop 3/3. Baseline DSL comparison and real CNN scheduling/execution benchmark passed. The local L2 harness is absent.
ForsakenDelusion
force-pushed
the
docs/topic28-design
branch
2 times, most recently
from
October 19, 2026 17:38
7bb4887 to
1252b37
Compare
- Drop opaque t/g/r/n review-round prefixes from 90 test functions. - Rename round-named modules to domain names (review/stage files). - Share independent ONNX wire helpers via tests/topic28_onnx.py. - Keep allocator sweeps only where allocation affects the contract; semantic/bit-pattern matrices use one representative allocator. - Update delivery/review doc links and project memory.
- Remove test_topic28_ci_regressions.py: ONNX shape inference, benchmark failure reporting, topic06 cost gate, base slti encoder/emulator parity and greedy fallthrough belong to shared tests, not this topic. - Drop the Qwen/W2 audit check from the merge suite. - Rename the remainder to test_topic28_encoded_constants.py and name its tests by contract.
ForsakenDelusion
force-pushed
the
docs/topic28-design
branch
from
October 22, 2026 15:10
776d9fb to
179fff6
Compare
Preserve upstream static ONNX input validation alongside scalar constant fidelity. Initialize named bindings for both base and extended selectors, and cover the integration with actual RV32 execution.
jizhenjun
approved these changes
Oct 23, 2026
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.
Summary
增加除法、余数、平方根、min/max、符号操作、访存及比较分支,提供四个 DSL 示例、支持列表和使用说明。R1–R4 的 LLVM 失败处理、函数内部重名、常量编码和分配器复用问题已修复。后续 R5 也已修复:ONNX 浮点 Min/Max 在任意输入为 NaN 时返回 NaN,IR 执行器同步处理,DSL 保持既有规则。
合并最新
main时还修复了张量形状契约和循环基准回归:未知 ONNX 输出维度不再写成精确的零长度尺寸(真实dim_value=0仍保留),循环上界改为按需物化并使用有符号立即数比较,DSL 基准显式初始化累加器。Review 报告与修复记录
Evidence
e061861的生产代码上,新 NaN 专项测试为 156 失败、60 通过;加上纠正 ONNX 预期后的 96 项既有编码测试,共 216 失败、96 通过。After: 新增 216 项专项测试通过,既有编码测试继续检查位模式、ABI 和异常标志;R5 修复后的完整回归为 3826 passed,0 failed,0 skipped。
reshape形状不匹配,主测试与 W1/W2 部署验收同时失败。After: 未知维度保持未知,真实零长度维度仍可执行;新增动态维度、真实零维和分支执行回归,Qwen 两层模型 7 组输入、29 个检查点、6 项不变量全部通过。
After: Topic 06 循环组 3/3、DSL 基准 23/23 通过,成本门槛未放宽。
qemu-system-riscv64的用例、Windows 专属用例)。git diff --check通过。远端 Actions 结果以实际运行记录为准。Merge Danger
Door: two-way
代码和配置可通过回退提交恢复。
Blast Radius: 编译管线
影响共享前端、IR 优化、RISC-V 选择与分配、栈布局及部分基准工具。范围为 RV32 标量和硬件 F/D;内部 encoder/emulator 仍仅支持 RV32IM。
ONNX Min/Max 的 NaN 传播问题已修复。非 NaN 输入继续采用已记录的 RISC-V 符号零规则;本次验证不扩大为完整 ONNX 张量或所有浮点边界的支持承诺。