- Published on
Investigation · Part 3 of 20 · When the benchmark lies
When the Compiler Computes the Answer Before the Benchmark Runs
On my laptop, summing the numbers below one thousand takes 0.81 ns, and below one billion also 0.81 ns. black_box hid the value of n, but LLVM replaced the loop with a formula. I show the assembly, the IR, the LLVM pass, and a benchmark that really grows with n.