encyclopegia.org

Induction variable

In computer science, an induction variable is a variable that gets increased or decreased by a fixed amount on every iteration of a loop or is a linear function of another induction variable. For example, in the following loop, i and j are induction variables: for (i = 0; i

In computer science, an induction variable is a variable that gets increased or decreased by a fixed amount on every iteration of a loop or is a linear function of another induction variable. For example, in the following loop, i and j are induction variables: for (i = 0; i ==Application to strength reduction== A common compiler optimization is to recognize the existence of induction variables and replace them with simpler computations; for example, the code above could be rewritten by the compiler as follows, on the assumption that the addition of a constant will be cheaper than a multiplication. j = -17; for (i = 0; i This optimization is a special case of strength reduction. ==Application to reduce register pressure== In some cases, it is possible to reverse this optimization in order to remove an induction variable from the code entirely. For example: extern int sum; int foo(int n) { int j = 5; for (int i = 0; i This function's loop has two induction variables: i and j . Either one can be rewritten as a linear function of the other; therefore, the compiler may optimize this code as if it had been written extern int sum; int foo(int n) { for (int i = 0; i ==Induction variable substitution== Induction variable substitution is a compiler transformation to recognize variables which can be expressed as functions of the indices of enclosing loops and replace them with expressions involving loop indices. This transformation makes the relationship between the variables and loop indices explicit, which helps other compiler analysis, such as dependence analysis. Example: Input code: int c = 10; for (int i = 0; i Output code int c = 10; for (int i = 0; i ==Non-linear induction variables== The same optimizations can be applied to induction variables that are not necessarily linear functions of the loop counter; for example, the loop j = 1; for (i = 0; i may be converted to for (i = 0; i ==See also== Mathematical induction ==References== ==Further reading==

References

No reference rows published for this article.

Cite this article

MLA

"Induction variable." encyclopegia.org, 2023, https://encyclopegia.org/wiki/induction-variable. Accessed 24 November 2026.

Chicago

"Induction variable." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/induction-variable.

APA

encyclopegia.org. (2023). Induction variable. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/induction-variable

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Cut Above the Rest

enwiki · references available

Strung Up (Sweet album)

enwiki · references available

ACÉPO

enwiki · references available

Karyn Dwyer

enwiki · references available

Pseudo algebraically closed field

enwiki · references available

Ljubo Sirc

enwiki · references available

Diafana Krina

enwiki · references available

Roberts-class monitor

enwiki · references available

St Thomas' Church, Belfast

enwiki · references available

Agounit

enwiki · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1169995015 · 0.5 · snapshot enwiki-001169995015

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.