0xMiden / 0xMiden/compiler

Compare VM cycles for compiler intrinsics vs equivalent Rust-generated MASM

未關閉
#1,143 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
optimization
主要語言
Rust
星號
115
分支
84
平均合併
1 天 8 小時
30 天內合併 PR
15

描述

Some compiler intrinsics directly correspond to Rust standard-library operations. For example, `::intrinsics::i32::overflowing_mul` is equivalent to Rust's `i32::overflowing_mul`.

However, compiling Rust code that calls such a function does not necessarily produce MASM that calls the corresponding compiler intrinsic. For example, the `overflowing_mul_i32` arithmetic test calls `i32::overflowing_mul`, but the generated MASM does not call `::intrinsics::i32::overflowing_mul`.

I think it would be interesting to compare using the compiler intrinsic directly vs the MASM currently generated from equivalent Rust code. For `i32::overflowing_mul` I'd expect the intrinsic to be more performant.

Suggested comparison:

- MASM wrapper that calls `::intrinsics::i32::overflowing_mul` directly
- Rust wrapper that calls `i32::overflowing_mul`, compiled with midenc
- Consistent input/output for both wrappers to ensure fair comparison
- Cycle measurements for representative inputs, including edge cases

If the intrinsic is significantly cheaper, we can investigate whether the frontend/codegen should recognize the generated pattern and lower it to the compiler intrinsic.

貢獻指南

開啟貢獻指南

研究方向

Look at the overflowing_mul_i32 arithmetic test to see the current MASM output. Write a MASM wrapper that calls ::intrinsics::i32::overflowing_mul directly and a Rust wrapper that calls i32::overflowing_mul. Compare VM cycles for both with consistent inputs. The goal is to see if the intrinsic is more performant and whether the frontend should lower the pattern to the intrinsic.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
rust
領域
compilers
Issue 類型
功能
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。