News for hackers. Stuff that matters.
Re:Can you trust a compiler to optimize your code? by stabbles on Tuesday August 01, 2023 @12:07PM (#36957912)
Rust's borrow checker could probably be used for alias analysis, and avoid emitting redundant load instructions. That would give it a competitive advantage to C++. Does something like this exist yet?
Re:Can you trust a compiler to optimize your code? by cwzwarich on Tuesday August 01, 2023 @12:14PM (#36958048)
Rust actually already does this to some degree, using LLVM’s noalias annotations (after many years of exposing latent LLVM bugs and having to disable them). There’s more that can be done here, see e.g.

https://github.com/rust-lang/rust/issues/16515#issuecomment-...

There are also soundness issues around async/await:

https://github.com/rust-lang/rust/issues/63818

LLVM’s aliasing model isn’t really optimal for a language like Rust with very precise memory dependence information, but using anything else would mean making a whole new optimizer/backend from scratch.