I wrote fre for GCC (and working on llvm's next gvn) and long story short, GCC is more powerful, but it doesn't always run early enough, and is not iterated.
The general problem of detecting all herbrand equivalences is exponential time, even without trying to evaluate the code. So you can't win all the time anyway.
An extra complication in this example is that `std::accumulate` currently lacks `constexpr` support: http://stackoverflow.com/questions/32395408/why-arent-stdalg...
There's been a proposal to relax this limitation: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p020...
For now you could use a workaround in form of a range-based for loop: https://godbolt.org/g/aVEqlm or even https://godbolt.org/g/GDrFr5 (homogeneous types).
A fold expression is much cleaner, though (also supporting heterogeneous types): https://godbolt.org/g/Hrnkc1
You can't make sum constexpr in this case, though, since it calls a non-constexpr function, accumulate.
Well, target code gen is the job of a compiler. Optimization is a plus. It's like saying VC is good at compiling, but not optimizing.
Given people expect both from their compilers these days ...