Optimize `load_small` lowering for immediate pointers
- 主要語言
- Rust
- 星號
- 115
- 分支
- 84
- 平均合併
- 1 天 8 小時
- 30 天內合併 PR
- 15
描述
When an immediate pointer is not aligned, the code emitted in [`load_small`](https://github.com/0xMiden/compiler/blob/d3cd8cd4a2c1dfeae8a61643aa42734a35e3e840/codegen/masm/src/emit/mem.rs#L202) is equivalent to that for non-immediate pointers. However, knowing `addr` and `offset` should allow to save some cycles by:
- pre-calculating `offset * 8` instead of doing that in the VM: -2 cycles for `u32wrapping_mul`
- Using `U32ShrImm` instead of `U32Shr`: -15 cycles
- Avoiding some stack modifications
[Cycle count ref](https://0xmiden.github.io/miden-vm/user_docs/assembly/instruction_reference.html)
This path might be hit when accessing struct fields, for instance.
貢獻指南
研究方向
Examine the `load_small` function in codegen/masm/src/emit/mem.rs at line 202. Understand the current lowering logic for immediate pointers. Review the Miden VM instruction reference for cycle counts of U32Shr vs U32ShrImm and u32wrapping_mul. Identify where `addr` and `offset` are known to pre-calculate `offset * 8` and optimize stack operations. Test changes by compiling relevant Rust code that triggers this path, such as struct field access.
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- rust
- 領域
- compilers
- Issue 類型
- 重構
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 65/100