investigation of flow graphs optimization methods used in optimizing compilers

Post on 23-Feb-2016

30 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Investigation of flow graphs optimization methods used in optimizing compilers. Eugene Gavrin – MSc student. Universal compiler back-end. Tasks. Develop an universal internal representation of the program based on formal computational model - PowerPoint PPT Presentation

TRANSCRIPT

Investigation of flow graphs optimization methods used in optimizing compilers

Eugene Gavrin – MSc student

Universal compiler back-end

Load IR

Common optimizations

Program analysis

Unload to IR

IR

IR

Program analysis

Tasks

• Develop an universal internal representation of the program based on formal computational model

• Implement the set of common compiler optimizations

Internal representation

• AST• Control flow graph• Data flow graph• Call graph• Dependency graph• ...

Internal representation

• AST• Control flow graph• Data flow graph• Call graph• Dependency graph• ...

Internal representation

• AST• Control flow graph• Data flow graph• Call graph• Dependency graph• ...

Internal representation

• AST• Control flow graph• Data flow graph• Call graph• Dependency graph• ...

Internal representation

• AST• Control flow graph• Data flow graph• Call graph• Dependency graph• ...

Internal representation

• AST• Control flow graph• Data flow graph• Call graph• Dependency graph• ...

Internal representation

• Oriented graph• Nodes are functional

operators• Vertexes are data

dependencies• Each operator stores:

– Operation name– Input and output data

links– Meta data

31 86

10

Functional

40

10

Functional

197

69

81

116

7

Condition

TRUE100

P

3

106

114

4

X

Left

FALSE66

P

7

94

99

4

X

Right

TRUE FALSE

TRUE

3

7

If47

Internal representation (branching)

• Extended data flow model by Davis & Keller

• Selector and Distributor represents conditional statements

• Enough to represent any control operator– If / Switch– For / While

Optimizing transformations

• Constant folding;• Sub-expression evaluation;• Strength reduction;• Null sequences;• Combine operators;• Loop optimizations;• Branch Elimination;

Constant folding

Before After

printf

6

7 5

+

*

printf

3 2

Sub-expression evaluation

Before After

1

1

2

2

3

3

4

5

1

2

3

4

5

[1] (0/1)

var

Dead code elimination

Before

In

Hello World

Out

main

R

R

Dead code

After

In

Hello World

Out

main

R

R

Direct conversion

Before After

1

Slow op

Slow op

2

1

Fast op

2

Future plans

• СIL processing (.NET assembly)– Load– Unload– Compare results with MSFT .NET compiler

• Static program analysis

Q&A

top related