CONCEPT LIBRARY

Guarded loop versioning

Select a specialized loop using a sufficient precondition.

Overview

A compiler can create a fast loop and retain the original checked loop as a fallback. For indices 0 through n−1 into a slice of length L, n ≤ L is a sufficient bounds condition. If the guard fails, executing the checked version preserves observable effects before an invalid access. This is a conceptual transformation, not a guarantee that any particular compiler emits it. With L=8 and n=6, the simplified model replaces six per-access checks with one guard.

Further reading

Related concepts

Related papers

Referenced in issues