



































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Professor: Mahlke; Class: Advanced Compilers; Subject: Electrical Engineering And Computer Science; University: University of Michigan - Ann Arbor; Term: Winter 2004;
Typology: Study notes
1 / 43
This page cannot be seen from the preview
Don't miss anything!




































Recap: Backedge Coalescing
BB2^ c <= 0 c > 0
b <= 13
c <= 25
c > 25 d++
b++^
c++
c > 25 c <= 25 c++
b < 0^
b >= 0^ BB3 BB
b > 13
e < 34 e >= 34 a++
e++^ BB
BB2^ c <= 0 c > 0
b <= 13 BB
b < 0^
b >= 0^ BB^
e++
b > 13 b++
d++^ BB^
a++ e < 34
e >= 34
Recap: CDs Via Algorithm^ Entry
b < 0^
b >= 0 BB2^ c <= 0 c > 0
b <= 13
c <= 25
c > 25 d++
e++ BB3 (^) c++
BB4 b > 13 BB^
b++
a++
e < 34^
Exit
Recap: CMPP Creation^ Entry
b < 0^
b >= 0 BB2^ c <= 0 c > 0
b <= 13
c <= 25
c > 25 d++
e++ BB3 (^) c++
p1 = cmpp.ON (b < 0) if T
p2 = cmpp.ON (b >= 0) if T
p3 = cmpp.ON (c > 0) if T
p4 = cmpp.ON (b > 13) if T
p5 = cmpp.ON (c <= 0) if T
p5 = cmpp.ON (b <= 13) if T
p6 = cmpp.ON (b < 0) if T
p6 = cmpp.ON (c <= 25) if T
BB4 b > 13 BB^
b++
a++
e < 34^
Exit
Running Example – Control Flow Substitution
Loop:^ p1 = p2 = p3 = p4 = p5 = p6 = 0^ b = load(a) if T^ p1 = cmpp.ON (b < 0) if T^ p2 = cmpp.ON (b >= 0) if T^ p6 = cmpp.ON (b < 0) if T^ p3 = cmpp.ON (c > 0) if p1^ p5 = cmpp.ON (c <= 0) if p1^ p4 = cmpp.ON (b > 13) if p3^ p5 = cmpp.ON (b <= 13) if p3^ b = b + 1 if p4^ c = c + 1 if p5^ d = d + 1 if p1^ p6 = cmpp.ON (c <= 25) if p2^ e = e + 1 if p2^ a = a + 1 if p6^ bge e, 34, Done if p6^ jump Loop if T Done:
BB2^ c <= 0 c > 0
b <= 13
c <= 25
c > 25 d++
c++ BB b < 0^
b >= 0^ BB^
e++
BB4 b > 13 BB^
b++
a++
e < 34^
e >= 34
Step 4: CMPP Compaction^ Y^
Same source operands y Same guarding predicate y Same or opposite compare conditions
Class Problem^ if (a > 0) {
Region Formation + If-conversion
branches » predicated operations
Often bad to apply in blanketmode » Selectively apply
Extend a superblock tocontain if-converted code » Convert off-trace transitionsto on-trace » A hyperblock is born » Superblock is a special caseHB where all guardingpredicates are True
Negative 1: Resource Usage Resource usage is additive for all BBs that are if-converted
Case 1: Each BB requires 3 resources Assume processor has 2 resources No IC: 13 + .63 + .43 + 13 = 9
9 / 2 = 4.5 = 5 cycles IC: 1(3 + 3 + 3+ 3) = 12
12 / 2 = 6 cycles
BB
BB2 if p BB^
Case 2: Each BB requires 3 resources Assume processor has 6 resources No IC: 13 + .63 + .43 + 13 = 9
9 / 6 = 1.5 = 2 cycles IC: 1(3+3+3+3) = 12
12 / 6 = 2 cycles
BB3 if p2^ BB
100
Negative 2: Dependence Height Dependence height is max of for all BBs that are if-converted (dep height = schedule length with infinite resources)
Case 1: height(bb1) = 1, height(bb2) = 3 Height(bb3) =
^9 , height(bb4) = 2 No IC: 11 + .63 + .49 + 12 = 8.4 IC: 11 + 1MAX(3,9) + 1*3 = 13
Case 2: height(bb1) = 1, height(bb2) = 3 Height(bb3) =
^3 , height(bb4) = 2 No IC: 11 + .63 + .43 + 12 = 6 IC: 11 + 1MAX(3,3) + 1*2 = 6 BB
BB2 if p BB^
BB3 if p2^ BB
100
When To If-convert^ Y^
BB1 BB2 if p1 BB3 if p2 BB
The Hyperblock^ Y^
Block Selection^ Y^
Compute priority for other BB’s y Normalize against main path.
Max value = 1, Hazardous instructions reduce this to 0.5, 0.25, ...
Example - Step 1 - Block Selection
main path = 1,2,4,
num_ops = 5 + 8 + 3 + 2 = 18 weight = 80 Calculate the BSVs for BB3, BB5 assuming no hazards, K = 4 BSV3 = 4 x (20 / 2) x (18 / 80) = 9 BSV5 = 4 x (10 / 5) x (18 / 80) = 1.8 If Threshold = 2.0, select BB3 along with main path 10 BB2 - 8