Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Loop unrolling
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Advantages== The overhead in "tight" loops often consists of instructions to increment a pointer or index to the next element in an array ([[pointer arithmetic]]), as well as "end of loop" tests. If an optimizing compiler or assembler is able to pre-calculate offsets to each ''individually referenced'' array variable, these can be built into the [[machine code]] instructions directly, therefore requiring no additional arithmetic operations at run time. * Significant gains can be realized if the reduction in executed instructions compensates for any performance reduction caused by any increase in the size of the program. * [[Branch predictor|Branch penalty]] is minimized.<ref name="fog2012">{{cite web|url=http://www.agner.org/optimize/optimizing_assembly.pdf|quote=12.11 Loop unrolling |pages=100|title=Optimizing subroutines in assembly language|first=Agner|last=Fog|author-link=Agner Fog |date=2012-02-29 |access-date=2012-09-22| publisher=Copenhagen University College of Engineering}}</ref> * If the statements in the loop are independent of each other (i.e. where statements that occur earlier in the loop do not affect statements that follow them), the statements can potentially be executed in [[Parallel computing|parallel]]. * Can be implemented dynamically if the number of array elements is unknown at compile time (as in [[Duff's device]]). Optimizing compilers will sometimes perform the unrolling automatically, or upon request.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)