Опубликован: 12.07.2012 | Доступ: свободный | Студентов: 355 / 24 | Оценка: 4.00 / 4.20 | Длительность: 11:07:00
Специальности: Программист
Лекция 4:

Optimizing compiler. Loop optimizations

< Лекция 3 || Лекция 4: 123456 || Лекция 5 >

Loop distribution and loop fusion are inverse optimizations. The compiler must have heuristics to estimate the profit of such optimizations.

Loop distribution can increase performance by improving memory reference. It can be applied if a loop is working with many different arrays.

If there are a lot of different invariants inside the loop than loop distribution can improve register usage.

Loop distribution can be useful for auto parallelization or vectorization.


Рис. 4.7.

Loop fusion can be beneficial for small loops because of improving the instructional parallelism level and data reusability.

Different microprocessors have different criteria for profitability of this optimizations.


Рис. 4.8.

Loop peeling (splitting) is an optimization, which tries to simplify the loop detaching the extreme iterations.

This optimization can be useful for loop fusion.


Рис. 4.9.

Loop unrolling is an optimization designed to reduce the loop iteration number by merging several iterations. The goal of loop unrolling is to reduce loop control instructions and branch penalties. This optimization can improve instruction parallelism and reusability of data. Main disadvantage of this optimization is code expansion.


Рис. 4.10.

Complete unrolling is applied to small loops and can be very effective. As a general rule in the case of nested loops, inner loops are unrolled.

Loop interchange is a loop optimization, which changes the order of iteration variables. The major purpose of loop interchange is to improve the cache performance for accessing array elements.


Рис. 4.11.
< Лекция 3 || Лекция 4: 123456 || Лекция 5 >