User`s guide
Optimizing Loops
6-7
Optimizing Loops
Simple Indexing
(array_indexing) T his optim ization improves the performance of simple one-
and two-dimensional array index expressions. Without this optimization, all
array indexing uses the fully general array indexing function, which is not
optimized for one- and two-dimensional indexi ng. With this optimization
enabled, indexing uses faster routines that are optimized for simple indexing.
For example,
function y = test(x,i1,i2);
y = x(i1,i2);
If you compile this with the -O none option, you get
...
mlfAssign(
&y,
mlfIndexRef(mclVsa(x, "x"), "(?,?)", mclVsa(i1, "i1"),
mclVsa(i2, "i2")));
...
Compiling wit h -O none -O array_indexing:on gives
...
mlfAssign(
&y, mclArrayRef2(mclVsa(x, "x"), mclVsa(i1, "i1"),
mclVsa(i2,"i2")));
...
The mclArrayRef2 function is optimized for two-dimensional indexing.
mclArrayRef1 is used for one-dimensional i ndexing.
Loop Simplification
(optimize_integer_for_loops) This optimization detects when a loop starts
and increments with int egers and replaces the loop with a much simpler loop
that uses C integer variables instead of array valued variables. The
performance improvements with this optimization can be dramatic.