9.2.4.3.htm
来自「建立《编译原理网络课程》的目的不仅使学生掌握构造编译程序的原理和技术」· HTM 代码 · 共 105 行
HTM
105 行
<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.4.2.htm'" ></img></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='9.3.1.htm'" ></img></td>
</tr>
</table>
<br><br>
<font class="title2">9.2.4.3 删除归纳变量</font><br>
<table>
<tr>
<td>    </td>
<td class="content">
<p>
一、什么是归纳变量
</p>
</td>
</tr>
</table>
<table><tr><td>    </td>
<td class="content">
<p>
在做完强度削弱的流图(图9.13(a)左边的流图也是)中,我们应注意到:在B3的内循环中,因为4*j赋给t4,j和t4的值步伐一致地变化,每次j的值减1,t4的值减4;同理,在B2的内循环中,i和t2的值也步伐一致地变化,这样的标识符就叫做<font class = "definition2">归纳变量</font>。
</td></tr></table>
<table><tr><td>    </td>
<td class="content">
<p>
二、什么是删除归纳变量
</td></tr></table>
<table><tr><td>    </td>
<td class="content">
<p>
如果在循环中有两个或更多的归纳变量,也许可以只留一个,去掉其余的,这个过程称为删除归纳变量。
</td></tr></table>
<table><tr><td>    </td>
<td class="content">
<p>
<font class = "example">例9.4</font> 把强度削减用于B2和B3的内循环后,i和j的作用仅在于决定B4的测试结果。我们已知道i和t2满足关系t2:=4*i;j和t4满足关系t4:=4*j,那么测试t2>=t4等价于测试i>=j。我们用t2>=t4替代i>=j后,B2中的i和B3中的j就成了死变量,在这些块中对它们的赋值也就成了死代码,可以删除。删除结果如图9.13所示。
</td></tr></table>
<br>
<center> <img src="images/9_13.gif"></center>
<br>
<table><tr><td>    </td>
<td class="content">
<p>
</td></tr></table>
<table><tr><td>    </td>
<td class="content">
<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/9774/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>
<p>
<table>
<tr>
<td><font class="yanshi">观看演示</font></td>
<td><font color=blue onmouseover="javascript:style.cursor='hand'" onclick="javascript:open('applet/97/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>
<br>
<table align=right width=300>
<tr>
<td>
<img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='9.2.4.2.htm'" ></img></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='9.3.1.htm'" ></img></td>
</tr>
</table>
</BODY>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?