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
🔴 Bug: Infinite loop in _gen_synthetic_asm — Lines 67-90: The if/elif block has no else branch. When random.random() returns a value greater than redundant_lui_ratio + lui_ratio (possible when the sum < 1.0), no branch executes and i never increments, causing an infinite loop. Suggestion: Add an else branch that generates a single "normal" instruction and increments i by 1.
🟡 Fragile import path — Lines 14-16: sys.path.insert(0, PROJ_DIR) overrides standard imports and breaks if the script is moved or imported as a module. Consider using from ..backend import ... (relative import) or installing the package with pip install -e ..
🟡 Misleading output in density test — Lines 179-180: The printed ratio=0.1 only reflects lui_ratio; the fixed redundant_lui_ratio is not shown. This can confuse readers. Suggestion: Print both densities, e.g. pair_ratio=0.1, redundant_ratio=0.1.
💭 Unclear docstring — Line 49: redundant_lui_ratio description says "redundant LUI pattern" but doesn't explain the pattern (two consecutive LUI to same register with an unrelated instruction in between). Clarify for future maintainers.
💭 Redundant changes_list computation — Line 119: r[1].total_changes is accessed inside a loop, but stats from merge_constants_detailed is assumed to have this attribute. Ensure the attribute name matches the actual return type.
🔴 Bug: Incorrect test case — Line 44, parameter (0.6, 0.5): both values are valid probabilities (0–1), so _gen_synthetic_asm should not raise ValueError. Either remove this test case or change it to an invalid combination (e.g., (1.1, 0.0) is already covered).
🟡 Fragile assertion — Lines 179–183: reduction == tracked_changes assumes the only changes to instruction count are from merging and LUI removal. Any other optimization (e.g., dead code elimination, constant folding) will break this test. Consider relaxing to reduction >= tracked_changes or asserting only when other optimizations are disabled.
💭 Private import — Line 26: from benchmarks.bench_const_merge import _gen_synthetic_asm imports a private function. While acceptable in tests, consider renaming the function to public if it's intended for testing.
📁 docs/课题14-常量加载合并优化-开发文档初稿.md
🔴 关键矛盾:合并与删除顺序描述可能误导
第2.2节核心处理流程写“删除冗余lui → 合并lui+addi”。但实际实现中,若先删除冗余,可能错失合并机会(如lui t0,0x12345; lui t0,0x12345; addi t0,t0,0x678,删除第二个lui后暴露相邻对)。虽然固定点迭代会补偿,但建议明确迭代顺序,或改为“先合并,再删除冗余”以更直观匹配常见模式。
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.
No description provided.