Re:Popcount CPU instruction
by nwallin on Monday September 09, 2019 @01:25AM
(#20915401)
replacing sum 1..n with n\*(n-1): https://godbolt.org/z/nLV1vb
[ Parent
| on HN ]
Re:Popcount CPU instruction
by lifthrasiir on Monday September 09, 2019 @03:26AM
(#20915940)
That kind of thing is actually fully general, and called the scalar evolution (SCEV) analysis. LLVM for example has a full engine [1] for solving all sort of polynomial recurrences, so you can solve, say, sum i^2 with clang too: https://godbolt.org/z/-nHe78
[1] https://github.com/llvm-mirror/llvm/blob/master/lib/Analysis...