Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

original loop

for (int i = init,  i < limit;  i += stride) {  // loop with array range check
    ...
    if (scale*i + offset < a.length) {  // array range check
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="9ada29d1ffde3a66-64dad496-41184bdf-bfe2a417-81233c739d8878c03579a58f"><ac:plain-text-body><![CDATA[        ... a[scale*i+offset] ...
]]></ac:plain-text-body></ac:structured-macro>
    } else raise_uncommon_trap();
    ...
}

after loop predication

if ( scale * imax + offset < a.length ) {  // loop predicate. imax is the maximum value of i where init <= i < limit
    for (int i = init,  i < limit;  i += stride) {  // loop without array range check
         ...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="108d62d714cf6df5-95adbcf5-49a0424b-8336a26c-9882828600fadc44d4cfb39d"><ac:plain-text-body><![CDATA[         ... a[scale*i+offset] ...
]]></ac:plain-text-body></ac:structured-macro>
         ...
    }
} else raise_uncommon_trap();

...

Existing optimizations that perform elimination of checks inside the loops are iteration range splitting based.  The loop is peeled

...

The major disadvantage of iteration range splitting based check elimination is the dramatic increase in code size due to the copies

of the loop. In addition, the checks in the pre- and post-loops are not eliminated, and thus the performance gain is limited if when the iteration

space is small.

Compared with the iteration range splitting based check elimination, loop predication has the following advantages:

...

4. (for future work) Loop predication provides a unified interface that can be implemented (extended) to replace the existing iteration range

    splitting based check eliminations (loop peeling, partial peeling, range check elimination)

...