📄 9.2.3.htm
字号:
<html>
<head>
<title>编译原理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link type="text/css" rel="stylesheet" href="../css/specification.css">
</head>
<BODY>
<table align=right width=300>
<tr>
<td>
<img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='9.2.2.htm'" ></img></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='9.2.4.htm'" ></img></td>
</tr>
</table>
<br><br>
<font class="title2">9.2.3 死代码删除</font><br>
<table><tr><td>    </td>
<td class="content">
<p>
概念:
<p>
如果变量的值在程序的某一点以后还要引用,则称它在该点是活跃的;否则称它在该点是死亡的。死代码指其计算的值决不被引用的代码。
<p>
例如:
<p>     ......<br>
<p>     debug:=false<br>
<p>     <font color="#0000FF">if</font> (debug)
<font color="#0000FF">print</font> ......<br>
<p>     ......<br>
<p>
从数据流分析可能推断出,程序每到达这个语句,debug的值总是假。如果复写传播用false代替debug,那么打印语句是死代码,因为它不可能到达,可以从目标代码中删除。
<p>
更一般的,在编译时推断出一个表达式的值是常量,并且用该常量代替它,这种变换叫做<font class = "definition2">常量合并</font>。
<p>
复写传播的优点之一是它常常使得复写语句成为死代码(无用赋值)。例如:在图9.10的左边的B5中已删除了公共子表达式,经过复写传播和死代码删除后的B5显示在右边。
</td></tr></table>
<br>
<center> <img src="images/9_10.gif"></center>
<br>
<table><tr><td>    </td>
<td class="content">
<p>
经过死代码删除,删除了对t6、t7、t8、t9和t10赋值的无用的代码。
<p>
现在,我们把死代码删除运用于经过公共子表达式删除、复写传播后的整个流图,请看演示。
</td></tr></table>
<p>
<table>
<tr>
<td><font class="yanshi">    观看演示 </font></td>
<td><font color=blue onmouseover="javascript:style.cursor='hand'" onclick="javascript:open('applet/9221/Page1.htm','_blank','menu=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,left=100,top=100,width=800,height=600')">复写传播及死代码删除概念演示</font></td>
<td><img src="../images/yanshi.gif"></img></td>
</tr>
</table>
</p>
<table align=right width=300>
<tr>
<td>
<img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='9.2.2.htm'" ></img></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='9.2.4.htm'" ></img></td>
</tr>
</table>
</BODY>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -