You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🟡 LICM "Implementation" is a placeholder — The doc labels this as "Implementation" but _find_loops_and_hoist always returns 0 and never actually hoists instructions. Readers will copy it expecting a working pass. Mark it as "skeleton/pseudocode" or provide the real implementation.
🟡 --optimize alias wording is confusing — "--optimize remains an alias ... and still requires one of those three values" implies it previously took a value. If it previously was a bare flag, this is a breaking CLI change; if not, just say --optimize is now an alias for --opt-level and takes the same required value.
🟡 "left intact" is ambiguous — In the W3 ADD/SUB semantics, "NaN, infinity, and finite operations that overflow to infinity are left intact" could mean the constants are preserved or that the instruction stays unfolded. Clarify: "these cases are not folded; the original instruction is left unchanged."
🟡 Pass snippets omit name — The new intro says every IR pass defines a stable name, but the Peephole and LICM examples only show optimize. Add name = "peephole" / name = "licm" to the snippets, or note that the attribute is intentionally omitted for brevity.
💭 Forward-scan limitation should be stated — "The pass performs one forward scan" means folding one instruction can’t enable a fold later in the same invocation. If that’s intended for W3, document that no fixpoint/re-scan is performed.
💭 INT32 float conversion rule could be clearer — "integer-valued finite floats" is ambiguous for typed IR: does a FLOAT64 literal like 3.0 in an INT32 expression get converted, or is it treated as mixed/unsupported? Give a concrete example.
🟡 注释与行为矛盾 — 第 62-63 行注释写 “run() optimizes program in place and returns an immutable report”,但“in place 修改”本身就是副作用,与 “immutable report” 无关。更重要的是调用方可能没意识到 program 已被修改。若该函数确实有副作用,建议注释明确说明 “This mutates the program object”,或改为返回新程序。
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
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.
内容
ConstantFolder的 ADD/SUB 增加由 IRDataType驱动的类型化计算。Value并保持 use 关系。范围
本 PR 基于并依赖 #48(W2 统一 Pass 接口与 PassManager)。#48 合并后,本 PR 的差异会自动收敛为 W3 内容。
本 PR 仅实现课题 4 的 W3「ConstantFolder 第 1 版」。没有实现 W4 的 MUL/DIV 类型化语义、外层不动点或递归折叠,也没有修改 IRBuilder、前端、后端、PassManager 或其他优化算法。
验证
git diff --check通过