V2EX  ›  英汉词典
Enqueued related words: Peephole Optimization, Partial Evaluation

Constant Folding

释义 Definition

常量折叠:编译器优化技术之一,在编译期把只包含常量的表达式直接计算出结果,用计算后的常量替换原表达式,从而减少运行时计算开销。(常见于编译器、解释器的优化阶段;也常与“常量传播”一起出现。)

发音 Pronunciation (IPA)

/ˈkɒnstənt ˈfoʊldɪŋ/

例句 Examples

The compiler uses constant folding to replace 2 + 3 with 5.
编译器使用常量折叠把 2 + 3 替换成 5

After constant folding and other optimizations, the generated code ran faster and used fewer CPU cycles.
在进行常量折叠和其他优化之后,生成的代码运行更快、占用的 CPU 周期更少。

词源 Etymology

该术语由 constant(常量) + folding(折叠) 构成。这里的 “fold” 源于“折叠/合并”的含义,借用来表示把可在编译期“合并计算”的表达式折成一个更简单的常量结果;“folding”在函数式编程里也常指把一串数据“折叠”为一个值(如 reduce),与“把多步计算压缩成一步结果”的思路相近。

相关词 Related Words

文学与经典著作 Literary Works

  • Compilers: Principles, Techniques, and Tools(Aho, Lam, Sethi, Ullman,“龙书”)——在编译器优化章节中常讨论类似优化(含常量相关简化)。
  • Engineering a Compiler(Cooper & Torczon)——介绍中间表示上的优化,常量折叠通常作为基础优化出现。
  • Modern Compiler Implementation(Andrew W. Appel)——讲解编译器实现时的常见局部优化与简化规则,常量折叠属于典型示例。
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   1311 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 13ms · UTC 16:40 · PVG 00:40 · LAX 08:40 · JFK 11:40
♥ Do have faith in what you're doing.