




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





define this function over tuples as: <x,C> ^ <x,C> = <x,C> for constant C <x,C> ^ <x,C’> = <x,N> for different constants C and C’ <x,C> ^ <x,N> = <x,N> for constant C <x,C> ^ <x,U> = <x,C> for constant C <x,N> ^ <x,U> = <x,N> <x,N> ^ <x,N> = <x,N> <x,U> ^ <x,U> = <x,U> Transfer function -- Finding a way to compute Const_Out is the trickiest part of this question. We want to be sure that any constant explicitly defined by the block is in this set, plus any constants that enter the block and are not killed. In addition, we can create new constants in the block when constant values enter the block. For the statement, b:=a, we might not know that b is a constant until the fact that a is a constant finally becomes part of Const_In. For this reason, I’m going to initialize Const_Out as Const_In and then define the transfer function based on the way that the individual statements modify the Const_Out set (in a forward direction). Copy statements: b := a - update <b,Z> where <a,Z> is in Const_Out (where Z can be a constant, N or U) Binary operator: z := x op y – if x and y are constants c1 and c2, then update z to be constant = c1 op c2. If either x or y are not constants (N), then z is not a constant N. Otherwise, z is U Non-assignment statements do not modify Const_Out Initialize all blocks Const_In(b) = {<x,U> such that x is a variable in the program}
a b c d e f g h a i x1 = x4 = x1,x5 x5 = x7 = x6 = x3,x1 x8 = x6,x5 x2 = x7,x1 x3 = Visit order based on DFS of IDOM tree: a, b, c, d, f, i, e, g, h (not the only possible ordering) j a b c d e f g h k i x1 = x5 = x2 = x3 = x1,x5 x4 = x3,x5 x6 = x2x2,x3 Visit order based on DFS of IDOM tree: a, b, c, e, g, i, d, f, h, j, k (not the only possible ordering)
a b c d e f g h a i x1 = x4 = x1,x5 x5 = x8 = x
x7 = x2 = x x6 = x3,x1 x8 = x6* x8 = x6,x5 x2 = x1* x6 = x1* x4 = x1* x4 = x x2 = (x1,x7) x3 = x6 = x Some of these are on critical edges and so should sit in their own blocks but I was too lazy. Those assignments are marked with * j a b c d e f g h k i x1 = x3 = x1* x5 = x2 = x4 = x5* x6 = x x3 = x1,x5 x6 = x3* x4 = x3* x4 = x3,x5 x6 = x2x2,x3 x3 = x
Block IDom DF 1 - - 2 1 3. 3 1 3, 4 2 5 5 1 a1 = 2 b1 = 3 c1 = a1 + b d1 = a1 + a b2 = a e1 = a1 + b a2 = (a3,a1,a1)a3,a1,a1) b5 = (a3,a1,a1)b6,b2,b3) c3 = (a3,a1,a1)c4,c1,c2) f2 = (a3,a1,a1)f2,f0,f1) a3 = a2 + 1 b6 = d1 + f c4 = 3 c2 = 3 f1 = a1 + c b3 = 5 b4 = d1 + f e2 = e1 + 1 a4 = (a3,a1,a1)a3,a1) b7 = (a3,a1,a1)b6,b4) c5 = (a3,a1,a1)c4,c2) e3 = (a3,a1,a1)e1,e2) f3 = (a3,a1,a1)f2,f1) e4 = d1 + 1 f4 = e4 + c
var C va r C va r C va r C var C a1 2 b1 3 c1 5 e1 4 f1 5 a2 b2 2 c2 3 e2 5 f a3 b3 5 c3 e3 f a4 b4 9 c4 3 e4 5 f4 8 b5 c5 3 b d1 4 b a1 = 2 b1 = 3 c1 = 5 a1 + b d1 = 4 a1 + a b2 = 2 a e1 = 4 a1 + b a2 = (a3,a1,a1)a3,a1,a1) b5 = (a3,a1,a1)b6,b2,b3) c3 = (a3,a1,a1)c4,c1,c2) f2 = (a3,a1,a1)f2,f0,f1) a3 = a2 + 1 b6 = d1 + f c4 = 3 c2 = 3 f1 = 5 a1 + c b3 = 5 b4 = 9 d1 + f e2 = 5 e1 + 1 a4 = (a3,a1,a1)a3,a1) b7 = (a3,a1,a1)b6,b4) c5 = 3 (a3,a1,a1)c4,c2) e3 = (a3,a1,a1)e1,e2) f3 = (a3,a1,a1)f2,f1) e4 = 5 d1 + 1 f4 = 8 e4 + c