Loop Fusion Amid Complex Control Flow - LLVM.org

25 downloads 523 Views 228KB Size Report
... be preserved, but. – How do we deal with proximity amid complex control flows (and function calls)?. 2 ... loops and attempt to merge or collapse the suffices.
Loop Fusion Amid Complex Control Flow R Ramshankar Dibyendu Das AMD 1

Loop Fusion Two loops with proximity in control flow iterating over same large arrays – Will show poor scalability – Why? Loops on large arrays stride over memory that is too big to fit in the cache. – Loops can be fused if dependences can be preserved, but – How do we deal with proximity amid complex control flows (and function calls)?

2

Loop fusion with control dependence • Build from trivial loop fusion: adjacent loops – Loops are typically guarded by an if (i != end) condition – Control dependence graph: derive from the CFG • If two loops have the same or almost identical control dependence

3

Control dependence If (x) { A; } A is control-dependent on the block that contains the conditional branch BR (x == true), A (i.e., A is control-dependent on the block that decides to bypass A or go to A) •

Formally, a statement y is said to be control dependent on another statement x if – (1) there exists a non-trivial path from x to y such that every statement z≠x in the path is post-dominated by y and – (2) x is not post-dominated by y

• Added the control dependence construction algorithm from Kennedy/Allen

4

Generic CFG pattern containing natural loops int test(int A[], long size…) { long i =0; for (i=0; i < size; i++) { A[i] |= (1