Nullstone Logo

COMPANY
Home
Contacts
Customers
Testimonials

PRODUCTS
Overview
NULLSTONE for C
NULLSTONE for Java
Technical Overview

SUPPORT
Release Notes
Download
PGP Information
Service Report
Write Us

INFORMATION
Performance Results
Glossary of Terms

RELATED LINKS
Compiler Connection
Compiler Jobs

Previous Up Next
Induction Variable Elimination

Some loops contain two or more induction variables that can be combined into one induction variable.

Example:

The code fragment below has three induction variables (i1, i2, and i3) that can be replaced with one induction variable, thus eliminating two induction variables.

    int a[SIZE];
    int b[SIZE];
    
    void f (void)
    {
      int i1, i2, i3;
    
      for (i1 = 0, i2 = 0, i3 = 0; i1 < SIZE; i1++)
        a[i2++] = b[i3++];
      return;
    }
    

The code fragment below shows the loop after induction variable elimination.

    int a[SIZE];
    int b[SIZE];
    
    void f (void)
    {
      int i1;
    
      for (i1 = 0; i1 < SIZE; i1++)
        a[i1] = b[i1];
      return;
    }
    

Notes:

Induction variable elimination can reduce the number of additions (or subtractions) in a loop, and improve both run-time performance and code space.

Some architectures have auto-increment and auto-decrement instructions that can sometimes be used instead of induction variable elimination.

© 1990-2012 Nullstone Corporation. All Rights Reserved.