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
Unswitching

A loop containing a loop-invariant IF statement can be transformed into an IF statement containing two loops.

Example:

In the example below, the IF expression is loop-invariant, and can be hoisted out of the loop.

    for (i = 0; i < N; i++)
      if (x)
        a[i] = 0;
      else
        b[i] = 0;
    

After unswitching, the IF expression is only executed once, thus improving run-time performance.

    if (x)
      for (i = 0; i < N; i++)
        a[i] = 0;
    else
      for (i = 0; i < N; i++)
        b[i] = 0;
    

© 1990-2012 Nullstone Corporation. All Rights Reserved.