









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Various compiler optimization techniques, including optimization of intermediate code, register allocation, and assembly code optimization. It also covers topics like constant propagation, folding, and algebraic simplification. Examples of decaf code and its corresponding tac, as well as explanations of basic blocks and their connection in the flow graph.
Typology: Papers
1 / 16
This page cannot be seen from the preview
Don't miss anything!










CS143 Handout 33 Autumn 2007 November 26, 2007
Handout written by Maggie Johnson.
int arr[10000]; void Binky() { int i; for (i=0; i < 10000; i++) arr[i] = 1; } int arr[10000]; void Winky() { register int *p; for (p = arr; p < arr + 10000; p++) *p = 1; }
_fib: BeginFunc 68; _tmp0 = 1 ; _tmp1 = base < _tmp0 ; _tmp2 = base == _tmp0 ; _tmp3 = _tmp1 || _tmp2 ; IfZ _tmp3 Goto _L0 ; result = base ; Goto _L1; _L0: _tmp4 = 0 ; f0 = _tmp4 ; _tmp5 = 1 ; f1 = _tmp5 ; _tmp6 = 2 ; i = _tmp6 ; _L2: _tmp7 = i < base ; _tmp8 = i == base ; _tmp9 = _tmp7 || _tmp8 ; IfZ _tmp9 Goto _L3 ; _tmp10 = f0 + f1 ; result = _tmp1 0 ; f0 = f1 ; f1 = result ; _tmp11 = 1 ; _tmp12 = i + _tmp11 ; i = _tmp12 ; Goto _L2 ; _L3: _L1: Return result ; EndFunc
_tmp0 = 12 ; _tmp1 = arr + _tmp0 ; _tmp2 = *(_tmp1) ; li $t0, 12 lw $t1, - 8($fp) add $t2, $t1, $t lw $t3, 0($t2)
_tmp0 = *(arr + 12) ; lw $t0, - 8($fp) lw $t1, 12($t0)
x+0 = x 0+x = x x1 = x 1x = x 0/x = 0 x- 0 = x b && true = b b && false = false b || true = true b || false = b
b = 5 + a + 10 ; _tmp0 = 5 ; _tmp1 = _tmp0 + a ; _tmp2 = _tmp1 + 10 ; b = _tmp2 ; _tmp0 = 15 ; _tmp1 = a + _tmp ; b = _tmp1 ;
i2 = 2i = i+i = i << 1 i/2 = (int)(i0.5) 0 - 1 = - i f2 = 2.0 * f = f + f f/2.0 = f*0.
while (i < 100) { arr[i] = 0; i = i + 1; } L0:_tmp2 = i < 100; IfZ _tmp2 Goto _L1 ; _tmp4 = 4 * i ; _tmp5 = arr + _tmp4 ; *(_tmp5) = 0 ; i = i + 1 ; L1:
_tmp4 = arr ; L0:_tmp2 = i < 100; IfZ _tmp2 Goto _L1 ; *_tmp4 = 0; _tmp4 = _tmp4 + 4; i = i + 1 ; L1:
main() { int x, y, z; x = (1+20)* - x; y = xx+(x/y); y = z = (x/y)/(xx); }
tmp1 = 1 + 20 ; tmp2 = - x ; x = tmp1 * tmp2 ; tmp3 = x * x ; tmp4 = x / y ; y = tmp3 + tmp4 ; tmp5 = x / y ; tmp6 = x * x ; z = tmp5 / tmp6 ; y = z ;
tmp2 = - x ; x = 21 * tmp2 ; tmp3 = x * x ; tmp4 = x / y ; y = tmp3 + tmp4 ; tmp5 = x / y ; z = tmp5 / tmp3 ; y = z ;
exit[B] = avail[B] - killed[B] + defined[B]
main: BeginFunc 28; b = a + 2 ; c = 4 * b ; tmp1 = b < c; ifNZ tmp1 goto L1 ; b = 1 ; L1: d = a + 2 ; EndFunc ;
i = 10; j = 20; x = i + j; y = j + k;