Rust: Zero-Cost Abstraction in Action
idursun.com
Rust: Zero-Cost Abstraction in Action
1–10 of 46 posts
Re: Rust: Zero-Cost Abstraction in Action
#2Re: Rust: Zero-Cost Abstraction in Action
#3Seeing what
pub fn sum3(n: i32) -> i32 {
(1..n).sum() + (1..2*n).sum() + (1..(n + 2)).sum()
}
does would be more interesting to me.Also, while all the inline is rustc, I assume the "triangle number trick" is LLVM.
Re: Rust: Zero-Cost Abstraction in Action
#4Just generally curious.
Re: Rust: Zero-Cost Abstraction in Action
#5Re: Rust: Zero-Cost Abstraction in Action
#6There is nothing about zero const abstractions in this article, just basic compiler optimizations.
Re: Rust: Zero-Cost Abstraction in Action
#7What I’m interested is how the IL code for the compiler frontends for each of those languages are more well-optimizable for LLVM (in practical situations, not just a few lines of simple numerical code.) I’ve heard that you need to be careful about encoding IL code in the right way such that LLVM does not generate needless memcpy’s or something but I’m not that much of a compiler expert...
Re: Rust: Zero-Cost Abstraction in Action
#8Are compiler optimizations like summing a series done on an ad-hoc basis? Certainly the compiler couldn’t have discovered or inferred (not sure what term to use) that formula, no? Just generally curious.
Re: Rust: Zero-Cost Abstraction in Action
#9Are compiler optimizations like summing a series done on an ad-hoc basis? Certainly the compiler couldn’t have discovered or inferred (not sure what term to use) that formula, no? Just generally curious.
Re: Rust: Zero-Cost Abstraction in Action
#101: https://boats.gitlab.io/blog/post/zero-cost-abstractions/