Teach Time Encyclopedia - Learn About Our World
Home Page
Teach Time
Featured Topics

United States
by state

CITYology

Academic Disciplines

Historical Timelines

Themed Timelines

Calendars

Reference Tables

Biographies

How-tos



Tuesday, December 02, 2008

Constant propagation

In computer science constant propagation (cprop) is an optimization performed by compilers.

After cprop is carried out, expressions that really can be calculated at compiletime will be, and are replaced by their values. That is, known functions of known constants are constants, and are recognised as such.

Constant propagation is also able to change conditional branches to unconditional ones. The following code in C can be simplified using cprop:

int a(){
  int b;
  int c;
  
  b=3;
  c=b*4;
  if(c>10){
    c=c-10;
  }
  return c;
}

A good compiler will reduce this to:

int a(){
  return 2;
}

Easily be implemented on SSA form as published by Wegman and Zadeck in 1991.

Constant propagation is not to be confused with constant folding, which is implemented in the front-end.

See also: Control flow graph, Compiler optimization



Internet Hotel Solutions

Site Sponsors
AC Units
Baltimore Harbor
Boot Camp Grads
Bra Size
Burkittsville
College Hotels
Digital Harbor
Free Cell Phones
Golden Hare Travel
Golf Vacations
Golf Courses
Gourmet
Hair Styles
Hippodrome
iWoman
Lesson Plans
Maryland Hotels
MD Genealogy
Minor League Stuff
Motel Site
Ocean City
OC Real Estate
Old Agers
Office Supplies
Orlando
Pet Friendly Hotel
Room Prices
Savannah, GA
Ski Vacations
South Baltimore
Student Teaching
Travel Sources
University Hotels
Visit Military Bases
Washington, DC

Brought to you by NoChildLeftBehind.com and the Beaches and Towns Network, LLC.