User`s guide

6 Optimizing Performance
6-6
Optimizing Loops
Simple Indexing
(array_indexing) This optimization 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 indexing. 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(mclVa(x, "x"), "(?,?)", mclVa(i1, "i1"),
mclVa(i2, "i2")));
...
Compiling with -O none -O array_indexing:on gives
...
mlfAssign(
&y, mclArrayRef2(mclVa(x, "x"), mclVa(i1, "i1"),
mclVa(i2,"i2")));
...
The mclArrayRef2 function is optimized for two-dimensional indexing.
mclArrayRef1 is used for one-dimensional indexing.
Loop Simplification
(optimize_integer_for_loops) This optimization detects when a loop starts
and increments with integers. It 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.