2 ms·
It could be useful to assume that i won’t overflow and wrap, so some of the bounds checks can be optimized out. This is a very common example, but how hard is
by userbinator 8y ago
It could be useful to assume that i won’t overflow and wrap, so some of the bounds checks can be optimized out.
This is a very common example, but how hard is it for the compiler to prove that it won't overflow? I know in the general case it's the halting problem, but for specific cases (especially where a human inspecting the code would easily see) it should be easy --- especially those cases which warrant optimisation.
- jstimpfle 8y agoYou could go over your source code and see how many operations are done using non-constant data from non-local-scope sources. I would be pretty amazed by a compiler that could find all or most of my operations that don't overflow. Almost all never do, or shouldn't, but that's probably hard to prove and requires global analysis.