Strength Reduction for Induction Variables
Replace a repeated affine computation by updates to a derived induction variable and check that the arithmetic semantics agree.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
Consecutive values admit an incremental formula
If loop index \(i\) increases by one and a temporary is \(a+ci\), that temporary increases by \(c\). Introduce \(u=a+ci_0\) before the loop and update \(u\gets u+c\) on each advancing edge. Induction on the iteration proves both expressions agree for mathematical integers. For byte offsets, this can replace repeated indexing arithmetic by simple address progression.
Preserve behavior at edges and overflow boundaries
The update must occur once for each original index change, including paths with continue or early exit. Wrapping fixed-width arithmetic can preserve the identity modulo the word size, but trapping overflow or a proof-relevant no-overflow flag changes what must be justified. An extra carried value can also raise register pressure. SSA phi functions explain how an induction variable appears across a back edge. Instruction selection determines when address arithmetic already fits an efficient machine instruction.[1][2]