Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1....

80
Waddle Always-Canonical Intermediate Representation Eric Fritz August 4, 2016 University of Wisconsin – Milwaukee

Transcript of Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1....

Page 1: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

WaddleAlways-Canonical Intermediate Representation

Eric FritzAugust 4, 2016

University of Wisconsin – Milwaukee

Page 2: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

10,000 Foot View

- LLVM 2.9 -O2 Passes

1 while i < n do2 if i&1 = 0 then3 a[i]← a[i− 1] ∗ 24 else5 a[i]← a[i− 2] ∗ 36 end7 i← i+ 18 end9 return a

i < n

i&1 = 0

a[i]← a[i− 1] ∗ 2

a[i]← a[i− 2] ∗ 3

i← i+ 1

return a

1

Page 3: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

10,000 Foot View

- LLVM 2.9 -O2 Passes

1 while i < n do2 if i&1 = 0 then3 a[i]← a[i− 1] ∗ 24 else5 a[i]← a[i− 2] ∗ 36 end7 i← i+ 18 end9 return a

i < n

i&1 = 0

a[i]← a[i− 1] ∗ 2

a[i]← a[i− 2] ∗ 3

i← i+ 4

return a

a[i+ 0]← a[i− 1] ∗ 2a[i+ 1]← a[i− 1] ∗ 3a[i+ 2]← a[i+ 1] ∗ 2a[i+ 3]← a[i+ 2] ∗ 3

1

Page 4: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

10,000 Foot View - LLVM 2.9 -O2 Passes

1. no/tb/basic-aa

2. domtree

3. verify

4. lowersetjmp

5. globalopt

6. ipsccp

7. deadargelim

8. basiccg

9. prune-eh

10. inline

11. functionattrs

12. argpromotion

13. scalarrepl-ssa

14. domtree

15. early-cse

16. simplify-libcalls

17. lazy-value-info

18. jump-threading

19. tailcallelim

20. reassociate

21. domtree

22. loops

23. loop-simplify

24. lcssa

25. loop-rotate

26. licm

27. lcssa

28. loop-unswitch

29. scalar-evolution

30. loop-simplify

31. lcssa

32. iv-users

33. indvars

34. loop-idiom

35. loop-deletion

36. loop-unroll

37. memdep

38. gvn

39. memdep

40. memcpyopt

41. sccp

42. lazy-value-info

43. jump-threading

44. domtree

45. memdep

46. dse

47. adce

48. strip-dead-prototypes

49. deadtypeelim

50. globaldce

51. constmerge

52. globalopt

53. ipsccp

54. deadargelim

55. basiccg

56. prune-eh

57. inline

58. functionattrs

59. scalarrepl-ssa

60. domtree

61. early-cse

62. simplify-libcalls

63. lazy-value-info

64. jump-threading

65. tailcallelim

66. reassociate

67. domtree

68. loops

69. loop-simplify

70. lcssa

71. loop-rotate

72. licm

73. lcssa

74. loop-unswitch

75. scalar-evolution

76. loop-simplify

77. lcssa

78. iv-users

79. indvars

80. loop-idiom

81. loop-deletion

82. loop-unroll

83. memdep

84. gvn

85. memdep

86. memcpyopt

87. sccp

88. lazy-value-info

89. jump-threading

90. domtree

91. memdep

92. dse

93. adce

94. strip-dead-prototypes

95. deadtypeelim

96. constmerge

97. domtree

98. verify

1

Page 5: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Structure of Talk

1. Auxiliary Structures, IRs

2. Motivation

3. SSA Reconstruction

4. Dominator Tree Reconstruction

5. Canonical Form Preservation

6. Tasklist

2

Page 6: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Auxiliary Structures, IRs

Page 7: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Domination

s

h

c

t

l

f

r

3

Page 8: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Domination

s

h

c

t

l

f

r

3

Page 9: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Domination

s

h

c

t

l

f

r

3

Page 10: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Domination

s

h

c

t

l

f

r

3

Page 11: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Domination

s

h

c

t

l

f

r

3

Page 12: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Domination - An (Extremely) Condensed History

• Purdom-Moore, 1972• Lengauer-Tarjan, 1979• Buschbaum, 1998• Cooper, 2001• Georgiadis, 2005

4

Page 13: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Loops & Loop Nesting Forest

a

b

c

ed

q

r

f

hg

i j

k

b

c e

f

{b, e, c, d, q, r}{g, k}

{c, d}{e}

{e, r, q}{b, k}

{f, h}{g, j}

5

Page 14: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Loops & Loop Nesting Forest

a

b

c

ed

q

r

f

hg

i j

k

b

c e

f

{b, e, c, d, q, r}{g, k}

{c, d}{e}

{e, r, q}{b, k}

{f, h}{g, j}

5

(1) Identify Backedge

Page 15: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Loops & Loop Nesting Forest

a

b

c

ed

q

r

f

hg

i j

k

b

c e

f

{b, e, c, d, q, r}{g, k}

{c, d}{e}

{e, r, q}{b, k}

{f, h}{g, j}

5

(2) Identify Header

Page 16: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Loops & Loop Nesting Forest

a

b

c

ed

q

r

f

hg

i j

k

b

c e

f

{b, e, c, d, q, r}{g, k}

{c, d}{e}

{e, r, q}{b, k}

{f, h}{g, j}

5

(3) Identify Dominated Blocks

Page 17: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Loops & Loop Nesting Forest

a

b

c

ed

q

r

f

hg

i j

k

b

c e

f

{b, e, c, d, q, r}{g, k}

{c, d}{e}

{e, r, q}{b, k}

{f, h}{g, j}

5

(4) Trace from latch

Page 18: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Loops & Loop Nesting Forest

a

b

c

ed

q

r

f

hg

i j

k

b

c e

f

{b, e, c, d, q, r}{g, k}

{c, d}{e}

{e, r, q}{b, k}

{f, h}{g, j}

5

(4) Trace from latch

Page 19: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Loops & Loop Nesting Forest

a

b

c

ed

q

r

f

hg

i j

k

b

c e

f

{b, e, c, d, q, r}{g, k}

{c, d}{e}

{e, r, q}{b, k}

{f, h}{g, j}

5

(4) Trace from latch

Page 20: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Loops & Loop Nesting Forest

a

b

c

ed

q

r

f

hg

i j

k

b

c e

f

{b, e, c, d, q, r}{g, k}

{c, d}{e}

{e, r, q}{b, k}

{f, h}{g, j}

5

(5) Identify Exits

Page 21: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Loops & Loop Nesting Forest

a

b

c

ed

q

r

f

hg

i j

k

b

c e

f

{b, e, c, d, q, r}{g, k}

{c, d}{e}

{e, r, q}{b, k}

{f, h}{g, j}

5

Page 22: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Loop Nesting Forest - An (Extremely) Condensed History

• Tarjan, 1973• Steensgaard, 1993• Sreedhar, 1996• Havlak, 1997

6

Page 23: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Static Single Assignment Form

p ← 1i1 ← 2

i3 ← ϕ(i1, i2)i3 < n

r ← n % i3r ?

= 0

p ← 0

i2 ← i3 +1

. . .

X ← · · · p · · ·

7

Page 24: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Static Single Assignment Form

p1 ← 1i1 ← 2

i3 ← ϕ(i1, i2)i3 < n

r ← n % i3r ?

= 0

p2 ← 0

i2 ← i3 +1

. . .

X ← · · · p? · · ·

7

(1) Generate unique assignment targets

Page 25: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Static Single Assignment Form

p1 ← 1i1 ← 2

i3 ← ϕ(i1, i2)i3 < n

r ← n % i3r ?

= 0

p2 ← 0

i2 ← i3 +1

. . .

X ← · · · p? · · ·

7

(2a) Determine join points with ‘dominance frontier’

Page 26: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Static Single Assignment Form

p1 ← 1i1 ← 2

i3 ← ϕ(i1, i2)i3 < n

r ← n % i3r ?

= 0

p2 ← 0

p3 ← ϕ( p? , p? )

i2 ← i3 + 1

. . .

X ← · · · p? · · ·

7

(3a) Place ϕ-nodes

Page 27: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Static Single Assignment Form

p1 ← 1i1 ← 2

i3 ← ϕ(i1, i2)i3 < n

r ← n % i3r ?

= 0

p2 ← 0

p3 ← ϕ( p? , p? )

i2 ← i3 + 1

. . .

X ← · · · p? · · ·

7

(2b) Determine join points with ‘dominance frontier’

Page 28: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Static Single Assignment Form

p1 ← 1i1 ← 2

p4 ← ϕ( p? , p? )

i3 ← ϕ(i1, i2)i3 < n

r ← n % i3r ?

= 0

p2 ← 0

p3 ← ϕ( p? , p? )

i2 ← i3 + 1

. . .

X ← · · · p? · · ·

7

(3b) Place ϕ-nodes

Page 29: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Static Single Assignment Form

p1 ← 1i1 ← 2

p4 ← ϕ( p1 , p3 )

i3 ← ϕ(i1, i2)i3 < n

r ← n % i3r ?

= 0

p2 ← 0

p3 ← ϕ( p2 , p4 )

i2 ← i3 + 1

. . .

X ← · · · p4 · · ·

7

(4) Rewrite uses with RD

Page 30: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Loop-Closed Static Single Assignment Form

p1 ← 1i1 ← 2

p4 ← ϕ( p1 , p3 )

i3 ← ϕ(i1, i2)i3 < n

r ← n % i3r ?

= 0

p2 ← 0

p3 ← ϕ( p2 , p4 )

i2 ← i3 + 1

. . .

X ← · · · p4 · · ·

7

Loop Closed: No uses outside loop of register defined within loop

Page 31: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Loop-Closed Static Single Assignment Form

p1 ← 1i1 ← 2

p4 ← ϕ( p1 , p3 )

i3 ← ϕ(i1, i2)i3 < n

r ← n % i3r ?

= 0

p2 ← 0

p3 ← ϕ( p2 , p4 )

i2 ← i3 + 1

p5 ← ϕ(p4)

. . .

X ← · · · p5 · · ·

7

Loop Closed: No uses outside loop of register defined within loop

Page 32: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

SSA - An (Extremely) Condensed History

• Cytron & Rosen & Zadeck, 1991• Choi, 1991• Briggs, 1998• Braun & Hack, 2013

• (LCSSA) Zadeck (?), After 1991 (Probably)

8

Page 33: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Canonical Form

h

ϵ

p1 p2

b1

l1

ϵ

l2

ϵ

e1

e2

ϵ

e39

Page 34: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Canonical Form

h

ϵ

p1 p2

b1

l1

ϵ

l2

ϵ

e1

e2

ϵ

e39

(Property 1) Dedicated preheader

Page 35: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Canonical Form

h

ϵ

p1 p2

b1

l1

ϵ

l2

ϵ

e1

e2

ϵ

e39

(Property 2) Single Latch

Page 36: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Canonical Form

h

ϵ

p1 p2

b1

l1

ϵ

l2

ϵ e1

e2

ϵ

e39

(Property 3) ∀b ∈ exit(L), pred(b) ⊆ L

Page 37: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Canonical Form

h

ϵ

p1 p2

b1

l1

ϵ

l2

ϵ e1

e2

ϵ

e39

(Property 3) ∀b ∈ exit(L), pred(b) ⊆ L

Page 38: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Motivation

Page 39: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Loop Unswitching + If Simplification

i1 ← 0

i3 ← ϕ(i1, i2)i3 < n

x ?= null

a[i3]?= null

t← eq(x, a[i3])t ?= 1

i2 ← i3 + 1

i3 ← ϕ(i1, i2)i3 < n

x ?= null

a[i3]?= null

t← eq(x, a[i3])t ?= 1

i2 ← i3 + 1

ret − 1

ret i3

10

Page 40: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Loop Unswitching + If Simplification

i1 ← 0x ?= null

i3 ← ϕ(i1, i2)i3 < n

false

a[i3]?= null

t← eq(x, a[i3])t ?= 1

i2 ← i3 + 1

i3 ← ϕ(i1, i2)i3 < n

true

a[i3]?= null

t← eq(x, a[i3])t ?= 1

i2 ← i3 + 1

ret − 1

ret i3

10

Page 41: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Loop Unswitching + If Simplification

i1 ← 0x ?= null

i3 ← ϕ(i1, i2)i3 < n

a[i3]?= null

t← eq(x, a[i3])t ?= 1

i2 ← i3 + 1

i3 ← ϕ(i1, i2)i3 < n

a[i3]?= null

i2 ← i3 + 1

ret − 1

ret i3

10

Page 42: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

SSA Reconstruction

Page 43: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Search-Based Algorithm (Braun 2013)

x2 ← · · ·x3 ← · · ·

x1 ← · · ·x2 ← · · ·x3 ← · · ·

· · · ← x?

a b

h

c

d e

11

Starting from a use, search←G for RDs

Page 44: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Search-Based Algorithm (Braun 2013)

x2 ← · · ·x3 ← · · ·

x1 ← · · ·x2 ← · · ·x3 ← · · ·

· · · ← x?

a b

h

c

d e

e 7→RD(d)

11

If a block does not define x, search its predecessors

Page 45: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Search-Based Algorithm (Braun 2013)

x2 ← · · ·x3 ← · · ·

x1 ← · · ·x2 ← · · ·x3 ← · · ·

· · · ← x?

a b

h

c

d e

e 7→RD(d)d 7→ RD(c)⊕RD(h)= t1

11

If a block has multiple predecessors, join result of predecessors

Page 46: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Search-Based Algorithm (Braun 2013)

x2 ← · · ·x3 ← · · ·

x1 ← · · ·x2 ← · · ·x3 ← · · ·

· · · ← x?

a b

h

c

d e

e 7→RD(d)d 7→ RD(c)⊕RD(h)= t1c 7→RD(h)

11

Page 47: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Search-Based Algorithm (Braun 2013)

x2 ← · · ·x3 ← · · ·

x1 ← · · ·x2 ← · · ·x3 ← · · ·

· · · ← x?

a b

h

c

d e

e 7→RD(d)d 7→ RD(c)⊕RD(h)= t1c 7→RD(h)h 7→ RD(a)⊕RD(b)⊕RD(d)= t2

11

Page 48: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Search-Based Algorithm (Braun 2013)

x2 ← · · ·x3 ← · · ·

x1 ← · · ·x2 ← · · ·x3 ← · · ·

· · · ← x?

a b

h

c

d e

e 7→RD(d)d 7→ RD(c)⊕RD(h)= t1c 7→RD(h)h 7→ RD(a)⊕RD(b)⊕ t1 = t2

11

RD(d) term collapses

Page 49: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Search-Based Algorithm (Braun 2013)

x2 ← · · ·x3 ← · · ·

x1 ← · · ·x2 ← · · ·x3 ← · · ·

· · · ← x?

a b

h

c

d e

e 7→RD(d)d 7→ RD(c)⊕RD(h)= t1c 7→RD(h)h 7→ RD(a)⊕RD(b)⊕ t1 = t2a 7→ x1b 7→ x3

11

Use last definition of x in block

Page 50: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Search-Based Algorithm (Braun 2013)

t2 ← ϕ(x1, x3, t1 )

x2 ← · · ·x3 ← · · ·

x1 ← · · ·x2 ← · · ·x3 ← · · ·

· · · ← x?

a b

h

c

d e

e 7→RD(d)d 7→ RD(c)⊕RD(h)= t1c 7→RD(h)h 7→ x1 ⊕ x3 ⊕ t1 = t2a 7→ x1b 7→ x3

11

RD(a) and RD(b) terms collapse, RD(h) has concrete ϕ-arguments

Page 51: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Search-Based Algorithm (Braun 2013)

t2 ← ϕ(x1, x3, t1 )

x2 ← · · ·x3 ← · · ·

x1 ← · · ·x2 ← · · ·x3 ← · · ·

· · · ← x?

a b

h

c

d e

e 7→RD(d)d 7→ RD(c)⊕ t2 = t1c 7→ t2h 7→ x1 ⊕ x3 ⊕ t1 = t2a 7→ x1b 7→ x3

11

RD(h) term collapses

Page 52: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Search-Based Algorithm (Braun 2013)

t2 ← ϕ(x1, x3, t1 )

x2 ← · · ·x3 ← · · ·

x1 ← · · ·x2 ← · · ·x3 ← · · ·

· · · ← x?

a b

h

c

d e

e 7→RD(d)d 7→ t2 ⊕ t2 = t1c 7→ t2h 7→ x1 ⊕ x3 ⊕ t1 = t2a 7→ x1b 7→ x3

11

RD(c) term collapses

Page 53: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Search-Based Algorithm (Braun 2013)

t2 ← ϕ(x1, x3, t2 )

x2 ← · · ·x3 ← · · ·

x1 ← · · ·x2 ← · · ·x3 ← · · ·

· · · ← x?

a b

h

c

d e

e 7→RD(d)d 7→ t2 ⊕ t2 = t2c 7→ t2h 7→ x1 ⊕ x3 ⊕ t2 = t2a 7→ x1b 7→ x3

11

t1 = ϕ(t2, t2) is trivially unnecessary

Page 54: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Search-Based Algorithm (Braun 2013)

t2 ← ϕ(x1, x3, t2 )

x2 ← · · ·x3 ← · · ·

x1 ← · · ·x2 ← · · ·x3 ← · · ·

· · · ← t2

a b

h

c

d e

e 7→ t2d 7→ t2 ⊕ t2 = t2c 7→ t2h 7→ x1 ⊕ x3 ⊕ t2 = t2a 7→ x1b 7→ x3

11

RD(d) term collapses, RD(e) has a solution

Page 55: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Dominator Tree Reconstruction

Page 56: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Edge Deletion (Ramalingam & Reps 1994)

a

cb

d e

gf

i j

m

h

k l

12

Page 57: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Edge Deletion (Ramalingam & Reps 1994)

a

cb

d e

gf

i j

m

h

k l

12

Page 58: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Edge Deletion (Ramalingam & Reps 1994)

a

cb

d e

g

f

i

j

m

h

k l

12

Page 59: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Edge Deletion (Ramalingam & Reps 1994)

a

cb

d e

g

f

i

j

m

h

k l

12

Page 60: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Edge Deletion (Ramalingam & Reps 1994)

a

cb

d e

g

f

i

j

m

h

k l

12

Page 61: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Edge Deletion (Ramalingam & Reps 1994)

a

cb

d e

g

f

i

j

m

h

k l

12

Page 62: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Edge Insertion (Ramalingam & Reps 1994)

a

cb

d e

gf

i j

m

h

k l

12

Page 63: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Edge Insertion (Ramalingam & Reps 1994)

a

cb

d e

gf

i j

m

h

k l

12

Page 64: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Edge Insertion (Ramalingam & Reps 1994)

a

cb

d e

gf

i j

m

h

k l

12

Page 65: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Edge Insertion (Ramalingam & Reps 1994)

a

cb

d e

gf

i j

m

h

k l

12

Page 66: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Edge Insertion (Ramalingam & Reps 1994)

a

cb

d e

gf

i j

m

h

k l

12

Page 67: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Edge Insertion (Ramalingam & Reps 1994)

a

cb

d e

gf

i j

m

h

k l

12

Page 68: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Edge Insertion (Ramalingam & Reps 1994)

a

cb

d e

gf

i j

m

h

k l

12

Page 69: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Canonical Form Preservation

Page 70: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Block Splitting / Collapsing & Edge-Set Splitting

b1,2

b1

b2

b1,2

p2p1 p3

b ϵ

p2p1 p3

b

13

Page 71: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Edge Deletion

a

b

c d

e

fgg

h i

jl

m

o

n

q

p k

14

Page 72: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Edge Deletion

a

b

c d

e

fgg

h i

jl

m

o

n

q

p k

14

Page 73: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Edge Deletion

a

b

c d

e

fgg

h i

jl

m

o

n

q14

Page 74: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Edge Deletion

a

b

c d

e

fgg

h i

jl

m

o

n

q14

Page 75: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Edge Deletion

a

b

c d

e

fgg

h i

jl

m

o

n

q14

Page 76: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Edge Deletion

a

b

c d

e

fgg

h i

jl

m

o

n

q14

Page 77: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Edge Deletion

a

b

c d

e

fgg

h i

jl

m

o

n

q

ϵ

14

Page 78: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Tasklist

Page 79: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Remaining Work

1. Solidify Current Work2. CF Preservation on Edge Insertion (e.g. Jump Threading)3. Implement Bag of Optimizations4. Evaluation

15

Page 80: Waddle - Always-Canonical Intermediate Representation - PhD Proposal.pdf · Structure of Talk 1. Auxiliary Structures, IRs 2. Motivation 3. SSA Reconstruction 4. Dominator Tree Reconstruction

Questions?

15