Constant_propagation Constant_propagation

Constant propagation - Definition and Overview

Related Words: Attenuation, Book, Breeding, Broadcast, Broadcasting, Circulation, Crossbreeding, Diffraction, Diffusion, Dilution, Dispersion, Display, Dissemination, Dissipation, Distribution, Divergence, Endogamy, Evaporation

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;
}


Constant propagation can 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

Example Usage of propagation

pieldeasno: @SinkDeep @pareilodiac @endlesscities -numinal piracy: propagation of the gift (and the noise).
Mistkits: RT @tweetmeme How to build an intermittent misting system for plant propagation | Plant propagation Misting System http://bit.ly/4xIzox
Michiru: @propagation why aren't you on AIM :(
Copyright 2009 WordIQ.com - Privacy Policy  :: Terms of Use  :: Contact Us  :: About Us
This article is licensed under the GNU Free Documentation License. It uses material from the this Wikipedia article.