[fpc-devel] Debugging Loop Unroll Optimization
J. Gareth Moreton
gareth at moreton-family.com
Fri May 18 17:13:55 CEST 2018
I think based on both documented and observed behaviour, the following
definition would be appropriate:
The for-loop variable is undefined after the loop if the loop ran to
completion. It retains its last value if the loop exited in a controlled
way (goto, break, exit, ?) before running to completion.
I'm happy with that, although it might be best to simply say (goto, break
etc.) since it's hard to be completely exhaustive (since there's raise and
continue as well), and let's just hope that someone doesn't call a function
that then performs a long jump to a completely different routine!
For purposes of compiler optimisation, I would argue that,
internally, 'exit' is only necessary to check if the for-loop variable is
Result, but that's just nit-picking. I'm in two minds with 'raise'
because it's not always easy to determine where the exception is raised
(e.g. in a subroutine called by the for-loop, or triggered by an interrupt
signal such as a segmentation fault), and I wouldn't call it exiting the
loop in a controlled way.
Gareth aka. Kit.
fpc-devel maillist - fpc-devel at lists.freepascal.org 
 mailto:fpc-devel at lists.freepascal.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-devel