alloy-rs / alloy-rs/ruint

`algorithms/mod`: This only black-boxes `acc` so LLVM keeps the subtraction results

未关闭
#581 0 条评论 0 个 reaction 已指派 1 人 已被 @prestwich 认领 在 GitHub 查看
hack tracker
主要语言
Rust
星标
225
派生
70
平均合并
16 小时 54 分钟
30 天内合并 PR
8

描述

*On 2026-04-30 @prestwich wrote in [`836a44f`](https://github.com/recmo/uint/commit/836a44f22fd30281b354f7a5c54872e8852d2505) “Merge pull request #579 from DaniPopes/cmp-with-sub-revived”:*

This only black-boxes `acc` so LLVM keeps the subtraction results
alive long enough for the backend to recognize the `borrowing_sub` chain
and generate better code: https://github.com/rust-lang/rust/issues/143517
SAFETY: Writing to a local variable through a reference is safe.

```rust
for i in 0..a.len() {
let x;
(x, borrow) = borrowing_sub(a[i], b[i], borrow);
acc |= x;
}
// HACK: This only black-boxes `acc` so LLVM keeps the subtraction results
// alive long enough for the backend to recognize the `borrowing_sub` chain
// and generate better code: https://github.com/rust-lang/rust/issues/143517
// SAFETY: Writing to a local variable through a reference is safe.
unsafe { core::ptr::write_volatile(&mut acc, acc) };
(acc, borrow)
}

#[inline]

```
*From [`src/algorithms/mod.rs:188`](https://github.com/recmo/uint/blob/836a44f22fd30281b354f7a5c54872e8852d2505/src/algorithms/mod.rs#L188)*

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。