2 ms·
The earlier transformations are actually more impressive. Constant folding is almost always has a good RoI, so lots of compilers do it, and it's simple because,
by Ericson2314 7y ago
The earlier transformations are actually more impressive. Constant folding is almost always has a good RoI, so lots of compilers do it, and it's simple because, well, it's a constant there is no variables or partial eval needed. The others require lots of inlining before the final rule fires, and so are more ambitious.
Seeing 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.
- SAI_Peregrinus 7y agoGodbolt supports Rust, and can show the LLVM IR: https://godbolt.org/z/GsccW3 https://godbolt.org/z/GsccW3
- pjmlp 7y agoA bit offtopic, I love how Godbolt grew out of C++ community to embrace as much AOT toolchains as possible, kudos to Matt and everyone involved into making it happen.