91优化的主要种类 912一个实例 m-1;j=n;v=an; (9)j=j-1 while (1)i 10)t4=4*j do i=i+l; while(ai]v) do j=j-l; while(ail>);(12)if ts>v goto(9) if(i>=j break (13)if i>=j goto(23) X=all: al=ali: alllEx (15)x=a|t6l x=ai; aian: an=x
9.1 优化的主要种类 9.1.2 一个实例 i = m −1; j = n; v = a[n]; (9) j = j −1 while (1) { (10) t4 = 4 j do i = i +1; while(a[i]<v); (11) t5 = a[t4 ] do j =j −1;while (a[j]>v); (12) if t5>v goto (9) if (i >= j) break; (13) if i >=j goto (23) x=a[i]; a[i]=a[j]; a[j]=x; (14) t6 = 4 i } (15 ) x = a[t6 ] x=a[i]; a[i]=a[n]; a[n]=x; . .
9优化的主要种类 m B n 4*n 程序流图 atI B 4* v goto B B 3 ts>v goto B j goto B B4 B B
9.1 优化的主要种类 i = m −1 j = n t1 = 4 n v = a[t1 ] i = i + 1 t2 = 4 i t3 = a[t2 ] if t3 < v goto B2 B1 B2 j = j −1 t4 = 4 j t5 = a[t4 ] if t5 > v goto B3 if i >= j goto B6 B4 B3 B5 B6 • 程序流图
91优化的主要种类 913公共子表达式删除 Bs x=ai;a=ajl; ajl=x; t=4*i at6 * 4 a at,l= to 10=4*j atol goto B2
9.1 优化的主要种类 9.1.3 公共子表达式删除 B5 x=a[i]; a[i]=a[j]; a[j]=x; t6 = 4 i x = a[t6 ] t7 = 4 i t8 = 4 j t9 = a[t8 ] a[t7 ] = t9 t10 = 4 j a[t10] = x goto B2
91优化的主要种类 局部公共子表达式删除,复写传播,删除死代码 Bs x=ai;a=ajl; ajl=x; t=4*i at6 X=a[t6 44a ** a t6 =tg at,l= to at=x 10=4*j goto B2 atol goto B2
9.1 优化的主要种类 局部公共子表达式删除, 复写传播, 删除死代码 B5 x=a[i]; a[i]=a[j]; a[j]=x; t6 = 4 i x = a[t6 ] t7 = 4 i t8 = 4 j t9 = a[t8 ] a[t7 ] = t9 t10 = 4 j a[t10] = x goto B2 t6 = 4 i x = a[t6 ] t8 = 4 j t9 = a[t8 ] a[t6 ] = t9 a[t8 ] = x goto B2
9优化的主要种类 m B n 事n atul t2=4*i t3 <v goto B2 水 ts>v goto B 团ii>= j goto B|B B
9.1 优化的主要种类 i = m −1 j = n t1 = 4 n v = a[t1] i = i + 1 t2 = 4 i t3 = a[t2] if t 3 < v goto B 2 B 1 B 2 j = j − 1 t 4 = 4 j t 5 = a[t 4 ] if t 5 > v goto B 3 if i >= j goto B 6 B 4 B 3 B 5 B 6