Loops in flow

7,577 views 16 slides Mar 15, 2017
Slide 1
Slide 1 of 16
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16

About This Presentation

5th chapter


Slide Content

Loops in Flow Graphs BP150511 R. RAMYA

LOOPS IN FLOW GRAPHS We shall use the notion of a node “Dominating” another to define “Natural Loop” and the important special class of “ Reducible” of flow graphs. An algorithm for finding dominators and checking reducibility of flow graphs.

Dominators Natural loops Inner loops Pre-Headers Reducible flow graphs

Dominators d dom n – Node d of a CFG dominates node n if every path from the initial node of the CFG to n goes through d– The loop entry dominates all nodes in the loop The immediate dominator m of a node n is the last dominator on the path from the initial node to n – If d ≠ n and d dom n then d dom m

Build a dominator tree as follows: – Root is CFG entry node n0 – m is child of node n iff n= Idom ( m)

Natural Loops A back edge is is an edge a → b whose head b dominates its tail a Given a back edge n → d 1. The natural loop consists of d plus the nodes that can reach n without going through d 2. The loop header is node d • Unless two loops have the same header, they are disjoint or one is nested within the other – A nested loop is an inner loop if it contains no other loops

Natural Inner Loops Example

Natural Outer Loops Example

Pre-Headers To facilitate loop transformations, a compiler often adds a pre-header to a loop • Code motion, strength reduction, and other loop transformations populate the pre-header

Reducible Flow Graphs Reducible graph = disjoint partition in forward and back edges such that the forward edges form an acyclic (sub)graph.

VIDEO video1

THANK YOU
Tags