























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!
























Homework 1^ Y^ Due next Monday (1/27) @11:59pm^ Y^ Check out the class newsgroup for help/info^ Y^ Notes
Recap: Predicated Execution Example^ a = b + c^ if (a > 0)^ e = f + g^ else^ e = f / g^ h = i - j
add a, b, c bgt a, 0, L1 div e, f, g jump L2 L1: add e, f, g L2: sub h, i, j
add a, b, c if T p2 = a > 0 if T p3 = a <= 0 if T div e, f, g if p3 add e, f, g if p2 sub h, i, j if T
p2^ Æ^ BB2 p3^ Æ^ BB
Compare-to-Predicate Operations (CMPPs)^ Y^ How do we compute predicates
OR-type, AND-type Predicates^ p1 = 0^ p1 = cmpp_ON (r1 < r2) if T^ p1 = cmpp_OC (r3 < r4) if T^ p1 = cmpp_ON (r5 < r6) if T^ p1 = (r1 < r2) | (!(r3 < r4)) |^ (r5 < r5)^ Wired-OR into p
Generating predicated code for some source code requires OR-type predicates
Talk about these later – used for control height reduction
Use of OR-type Predicates^ a = b + c^ if (a > 0 && b > 0)^ e = f + g^ else^ e = f / g^ h = i - j
add a, b, c ble a, 0, L1 ble b, 0, L1 add e, f, g jump L2 L1: div e, f, g L2: sub h, i, j
add a, b, c if T p3, p5 = cmpp.ON.UC a <= 0 if T p3, p2 = cmpp.ON.UC b <= 0 if p5 div e, f, g if p3 add e, f, g if p2 sub h, i, j if T
p2^ Æ^ BB2 p3^ Æ^ BB3 p5^ Æ^ BB
If-conversion^ Y^ Algorithm for generating predicated code
But, acyclic subgraph only!! y Need a branch to get you back to the top of a loop
Running Example – Initial State^ do {^ b = load(a)^ if (b < 0) {
if ((c > 0) && (b > 13))^ b = b + 1 else^ c = c + 1 d = d + 1 } else { e = e + 1 if (c > 25) continue } a = a + 1 } while (e < 34)
BB2c > 0^ c <= 0 BB4b <= 13^ BB
BB1 b < 0 b >= 0
e+ BB3+ c > 25 c <= 25 c++
b > 13 b++
d++^ BB^
a++ e < 34
e >= 34
Running Example – Backedge Coalescing
b < 0^
b >= 0 c <= 0 c > 0
b <= 13
c <= 25^
c > 25 d++
e++
b++^
c++
b < 0^
b >= 0 c <= 0 c > 0 b <= 13
e++ c > 25c <= 25 c++
b > 13
e < 34 e >= 34 a++
BB4 b > 13 BB^
b++
d++^ BB^
a++ e < 34
e >= 34
Step 2: Control Dependence Analysis (CD)^ Y^ Control flow – Execution transfer from 1 BB to anothervia a taken branch or fallthrough path^ Y^ Dependence – Ordering constraint between 2 operations
Control Dependence Example
Control dependences BB1: BB2: BB3: BB4: BB5: BB6: BB7: BB
Notation positive BB number = fallthru direction^ negative BB number = taken direction BB
Running Example – CDs^ Entry
First, nuke backedge(s) Second, nuke exit edges Then, Add pseudo entry/exit nodes^ - Entry
Æ^ nodes with no predecessors - Exit Æ^ nodes with no successors
BB1 b < 0 b >= 0 c <= 0 c > 0
b <= 13
c <= 25^
c > 25 d++
e++ c++ BB^
b > 13^ BB
b++
a++^ BB
e < 34^
Exit
Running Example – Post Dominators^ Entry
b < 0^
b >= 0 c <= 0 c > 0
b <= 13
c <= 25^
c > 25 d++
e++ c++ BB^
BB4 b > 13 BB^
b++
a++^ BB
e < 34^
Exit
Running Example – CDs Via Algorithm
c <= 0 c > 0
b <= 13
c <= 25^
c > 25 d++
e++ c++ BB2 BB4^ BB
BB1 b < 0 b >= 0^ BB3^ BB b > 13
e < 34 a++ b++
x = 1e = taken edge 1
y = 2y not in pdom(x)lub = 9x_id = -1t = 22 != 9cd(2) += -1t = 77 != 9cd(7) += -1t = 88 != 9cd(8) += -1t = 99 == 9 1 Æ^ 2 edge (aka –1)
Entry
Exit