Chinaunix首页 | 论坛 | 博客
  • 博客访问: 367967
  • 博文数量: 715
  • 博客积分: 40000
  • 博客等级: 大将
  • 技术积分: 5005
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-13 14:46
文章分类

全部博文(715)

文章存档

2011年(1)

2008年(714)

我的朋友

分类:

2008-10-13 16:30:16

constant folding

A optimisation technique where constant subexpressions are evaluated at compile time. This is usually only applied to built-in numerical and operators whereas is more general in that expressions involving user-defined functions may also be evaluated at compile time.

const propagation

Constant propagation is the process of substituting the values of known constants in expressions at compile time. Such constants include those defined above, as well as applied to constant values. Consider the following pseudocode:

 int x = 14;
 int y = 7 - x / 2;
 return y * (28 / x + 2);

Applying constant propagation once yields:

 int x = 14;
 int y = 7 - 14 / 2;
 return y * (28 / 14 + 2);


My Misunderstanding: Previously I thought Const Folding will store different const vairables with same value in the same memory at run time.
But I'm wrong, the actual case is:

Const Folding doesn't mean that the different const vairable with the same value in different compilaton unit will be
stored in the same memory. I can give an example to show that. By default, const objects are local to the file
in which they are defined, so it is legal to put their definition in a header file.There is one important implication of
this behavior. When we define a const in a header file, every source file that includes that header has its own const
variable with the same name and value. But they are not saved in the same storage.



--------------------next---------------------

阅读(164) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~