查看“︁复制传播”︁的源代码
←
复制传播
跳转到导航
跳转到搜索
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{NoteTA|G1=IT}} 在[[计算机科学]]中,'''复制传播'''(copy propagation)是一种[[编译器]]优化技术,在[[GCC]]、[[LLVM]]等大型编译器中均有使用此技术。<ref>{{cite web |title=LLVM: lib/CodeGen/MachineCopyPropagation.cpp Source File |url=https://llvm.org/doxygen/MachineCopyPropagation_8cpp_source.html |website=llvm.org |access-date=2021-11-24 |archive-date=2021-11-24 |archive-url=https://web.archive.org/web/20211124051731/https://llvm.org/doxygen/MachineCopyPropagation_8cpp_source.html |dead-url=no }}</ref> 假设有一直接[[赋值语句]](direct assignment) <math>x := y</math> ,则 <math>x</math> 是其赋值目标, <math>y</math> 是这个赋值语句的值。那么复制传播便是将代码中所有出现的、能被替换的 <math>x</math> ,统统直接替换成该语句的值 <math>y</math> 的一个过程。<ref>{{cite web |author1=Marc Moreno Maza |title=Data-flow analysis: copy propagation. |url=https://www.csd.uwo.ca/~mmorenom/CS447/Lectures/CodeOptimization.html/node8.html |website=www.csd.uwo.ca |access-date=2021-11-24 |archive-date=2021-11-24 |archive-url=https://web.archive.org/web/20211124014627/https://www.csd.uwo.ca/~mmorenom/CS447/Lectures/CodeOptimization.html/node8.html |dead-url=no }}</ref> 在计算什么赋值目标能被安全地替换时,复制传播经常会使用到[[定义可达性]]、use-def链、def-use链这些算法。以 <math>x := y</math> 为例,如果 <math>x</math> 这个赋值目标在程序中的某个点 <math>p</math> 之前从未被重新赋值过,则在点 <math>p</math> 以前都可以安全地使用 <math>y</math> 替代 <math>x</math> 。 == 范例 == 对于以下代码: x = y z = 3 + x 经过复制传播转换后,会形成以下代码: z = 3 + y 可见原代码中多余的赋值操作已被复制传播消除。由于其它优化技术,如[[公共子表达式消除]]经常会产生这种类型的多余赋值操作,因此复制传播属于是一种尤为重要的“代码清理”优化。 == 相关链接 == * [[复制省略]] * [[常数折叠]] == 补充书目、地址与网址 == * Muchnick, Steven S. Advanced Compiler Design and Implementation. Morgan Kaufmann. 1997. == 参考 == <references/> [[Category:編譯器最佳化]]
该页面使用的模板:
Template:Cite web
(
查看源代码
)
Template:NoteTA
(
查看源代码
)
返回
复制传播
。
导航菜单
个人工具
登录
命名空间
页面
讨论
不转换
查看
阅读
查看源代码
查看历史
更多
搜索
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
工具
链入页面
相关更改
页面信息