On 2026-04-30 @prestwich wrote in 836a44f “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: rust-lang/rust#143517
SAFETY: Writing to a local variable through a reference is safe.
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
On 2026-04-30 @prestwich wrote in
836a44f“Merge pull request #579 from DaniPopes/cmp-with-sub-revived”:This only black-boxes
accso LLVM keeps the subtraction resultsalive long enough for the backend to recognize the
borrowing_subchainand generate better code: rust-lang/rust#143517
SAFETY: Writing to a local variable through a reference is safe.
From
src/algorithms/mod.rs:188