[fpc-devel] Debugging Loop Unroll Optimization
florian at freepascal.org
Thu May 17 21:06:19 CEST 2018
Am 17.05.2018 um 19:01 schrieb Martok:
> Same documentation for FPC, <https://www.freepascal.org/docs-html/ref/refsu58.html>
> But, someone clearly explicitly thought otherwise at some point:
Sometime ago, fpc behaved strange in case of for loops and dfa, so it might have been that the
compiler even didn't recognize that result is always initialized in the body or whatever.
> That warning is only "wrong" if Result is well-defined after exiting the loop.
>> So this shall not be unrolled, but is still error prone, if Result is not set after the regular end
>> of the for loop.
> Am I doing something wrong, or does FPC not emit a warning when a loop variable
> is read after the loop? Delphi has a warning, and does indeed display it for the
> test case. There is no indication anything might be wrong from FPC?
No, still on my todo list.
> This kind of code is used even more than "that other thing", makes me wonder if
> it's a good idea to break this at O3...
-O3 probably "breaks" a lot of code which exploits the limits of a language-
More information about the fpc-devel