⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 9.2.1.htm

📁 建立《编译原理网络课程》的目的不仅使学生掌握构造编译程序的原理和技术
💻 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.1.3_2.htm'" ></img></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='9.2.1_2.htm'" ></img></td>
</tr>
</table>
<br><br>

<font class="title2">9.2 优化的主要种类</font><br>

<table>
<tr>
<td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
两个概念:
</p>
</td>
</tr>
</table>

<table>
<tr>
<td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
1、 <font class = "definition2">局部优化</font>:考察一个基本块的语句就可以完成的优化叫做局部优化。
</p>
<p>
2、 <font class = "definition2">全局优化</font>:在整个程序范围内进行的优化叫做全局优化。
<p>
本节,介绍一些最有用的代码优化措施。许多优化措施可以在局部范围内完成(局部优化),也可以在全局范围内完成(全局优化)。通常首先完成局部优化。
</td></tr></table>

<hr size=2 width=90% align=center color=red><br>

<font class="title2">9.2.1 公共子表达式</font><br>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
一、概念:
<p>
如果表达式E先前已计算,并且从先前的计算至现在,E中变量的值没有改变,那么E的这次出现称为<font class = "definition2">公共子表达式</font>。
</td></tr></table>

<br>
<center>  <img src="images/9_6.gif"></center> 
<br>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
例如:有基本块B5,其中哪些是公共子表达式?
<p>
其中,t<sub>7</sub>:=4*i中的<font color="FF000000">4*i</font>和t<sub>10</sub>:=4*j中的<font color="FF000000">4*j</font>是公共子表达式。
<p>
二、 优化的方法----删除公共子表达式
<p>
我们看到,在B5中,对t<sub>7</sub>和t<sub>10</sub>的赋值分别有公共子表达式4*i和4*j在它们的右部。如果用t<sub>6</sub>代替t<sub>7</sub>;t<sub>8</sub>代替t<sub>10</sub>,删除这些公共子表达式,不就可以避免表达式的重复计算,达到优化的目的吗?
</p>
</td></tr></table>
<br>
<table align=right width=300>
<tr>
<td>
<img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='9.1.3_2.htm'" ></img></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='9.2.1_2.htm'" ></img></td>
</tr>
</table>

</BODY>
<html><script language="JavaScript">

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -