explain briefly loop-invariant code motion of the


Explain briefly Loop-invariant code motion of the commonly used code optimization techniques.

Loop-invariant code motion

If a quantity is calculated inside a loop during iteration and its value is similar for iteration, this can vastly improve efficiency to hoist this outside the loop and calculate its value just once before the loop begins. It is particularly significant with the address-calculation expressions generated through loops over arrays. For accurate implementation, such technique must be utilized with loop inversion, since not all code is safe to be hoisted outside the loop.

For illustration:

 for (i=1; i≤10, i++){

x=y*2-(1)

.

.

.

}

statement 1 can be hoisted outside the loop assuming value of x and y does not modify in the loop.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: explain briefly loop-invariant code motion of the
Reference No:- TGS0276857

Expected delivery within 24 Hours