Loop fusion
From Free net encyclopedia
Loop fusion is a compiler optimization, a loop transformation, which replaces multiple loops with a single one.
[edit]
Example in C
int i, a[100], b[100]; for (i = 0; i < 100; i++) { a[i] = 1; } for (i = 0; i < 100; i++) { b[i] = 2; }
is equivalent to:
int i, a[100], b[100]; for (i = 0; i < 100; i++) { a[i] = 1; b[i] = 2; }
[edit]
Note
Some optimizations like this don't always improve the run-time performance. This is due to architectures that provide better performance if there are two loops rather than one.
[edit]