
























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!

























Class Problem From Last Time
r1 = 0; r2 = 0
r111 = r5 * 2
r110 = r111 + 2
r109 = r1 << 1
r104 = r109 – 10
r113 = r2 – 1
r1 = 0 r2 = 0
r5 = r5 + 1
r11 = r5 * 2
r10 = r11 + 2
r12 = load (r10+0)
r9 = r1 << 1
r4 = r9 - 10
r3 = load(r4+4)
r3 = r3 + 1
store(r4+0, r3)
r7 = r3 << 2
r6 = load(r7+0)
r13 = r2 - 1
r1 = r1 + 1 r2 = r2 + 1
r6, r10, r12, r13 live
r5 = r5 + 1
r111 = r111 + 2 r110 = r110 + 2
r12 = load (r110+0)
r3 = load(r104+4)
r3 = r3 + 1
store(r104+0, r3)
r7 = r3 << 2
r6 = load(r7+0)
r1 = r1 + 1
r109 = r109 + 2 r104 = r104 + 2
r2 = r2 + 1
r113 = r113 + 1
r6, r110, r12, r113 live
Recap: Tree Height Reduction
Y
Re-compute expression as abalanced binary tree
Y
Effects
y
n-1 (assuming unit latency)
y
ceil(log2(n))
y
Temporary registers “live”longer
y
Always ok for integerarithmetic
y
Floating-point – may notbe!!
Class Problem
r10 = r1 * r2 r11 = r10 + r3 r12 = r11 + r4 r13 = r12 – r5 r14 = r13 + r
Register Renaming on Unrolled Loop
r1 = load(r2) r3 = load(r4) r5 = r1 * r3 r6 = r6 + r5 r2 = r2 + 4 r4 = r4 + 4
r1 = load(r2) r3 = load(r4) r5 = r1 * r3 r6 = r6 + r5 r2 = r2 + 4 r4 = r4 + 4
r1 = load(r2) r3 = load(r4) r5 = r1 * r3 r6 = r6 + r5 r2 = r2 + 4 r4 = r4 + 4
r11 = load(r2) r13 = load(r4) r15 = r11 * r13 r6 = r6 + r15 r2 = r2 + 4 r4 = r4 + 4
r1 = load(r2) r3 = load(r4) r5 = r1 * r3 r6 = r6 + r5 r2 = r2 + 4 r4 = r4 + 4 if (r4 < 400) goto loop
r21 = load(r2) r23 = load(r4) r25 = r21 * r23 r6 = r6 + r25 r2 = r2 + 4 r4 = r4 + 4 if (r4 < 400) goto loop
Register Renaming is Not Enough!
Y
Still not much overlap possible
Y
Problems
Y
2 specialized renaming optis
r1 = load(r2) r3 = load(r4) r5 = r1 * r3 r6 = r6 + r5 r2 = r2 + 4 r4 = r4 + 4
r11 = load(r2) r13 = load(r4) r15 = r11 * r13 r6 = r6 + r15 r2 = r2 + 4 r4 = r4 + 4
r21 = load(r2) r23 = load(r4) r25 = r21 * r23 r6 = r6 + r25 r2 = r2 + 4 r4 = r4 + 4 if (r4 < 400) goto loop
Induction Variable Expansion
r1 = load(r2)r3 = load(r4)r5 = r1 * r3r6 = r6 + r5r2 = r2 + 12r4 = r4 + 12r11 = load(r12)r13 = load(r14)r15 = r11 * r13r16 = r16 + r15r12 = r12 + 12r14 = r14 + 12r21 = load(r22)r23 = load(r24)r25 = r21 * r23r26 = r26 + r25r22 = r22 + 12r24 = r24 + 12if (r4 < 400) goto loop
r12 = r2 + 4, r22 = r2 + 8r14 = r4 + 4, r24 = r4 + 8r16 = r26 = 0 r6 = r6 + r16 + r
Y
Induction variable
Y
Create n-1 additional inductionvariables
Y
Each iteration uses andmodifies a different inductionvariable
Y
Initialize induction variables toinit, init+step, init+2*step, etc.
Y
Step increased to n*originalstep
Y
Now iterations are completelyindependent !!
Better Induction Variable Expansion
Y
With base+displacementaddressing, often don’t needadditional induction variables
r1 = load(r2)r3 = load(r4)r5 = r1 * r3r6 = r6 + r5r11 = load(r2+4)r13 = load(r4+4)r15 = r11 * r13r16 = r16 + r15r21 = load(r2+8)r23 = load(r4+8)r25 = r21 * r23r26 = r26 + r25r2 = r2 + 12r4 = r4 + 12if (r4 < 400) goto loop
r16 = r26 = 0 r6 = r6 + r16 + r
Control CPR: A Branch HeightReduction Optimization for EPICArchitectures PLDI - 1999
Mike Schlansker Scott Mahlke Hewlett-Packard Laboratories Richard Johnson Transmeta Corporation
Introduction and Problem Statement
Y
Data
Control
Long dependence chains
Sequential code
Y
High degree hardwareparallelism
Low degree of programparallelism
Resources idle most of the time
Y
Traditional compilers focus onreducing operation count
Future compilers need onincreasing program parallelism
Our Approach to Control Height Reduction
»
Reduce dependence height through a network of branches
»
Reduce number of executed branches
»
Applicable to a large fraction of the program
»
Fit into our existing compiler infrastructure
»
Reducing height while
»
Not increasing operation count
»
Use branch profile information
»
Optimize likely the important control flow paths
»
Possibly penalize less important paths
Definitions
E
branch store 1
E
branch
E
branch store 0 store 2
E
a
b
<
a
b
<
a
b
<
Y
single-entry linear sequence ofoperations containing 1 or morebranches
Our basic compilation unit
Non-speculative operations
Y
branch to allow early transfer outof the superblock
compare condition (ai
i
< bi) < bi)
Y
preferred execution path (E4)
identified by profiling
Y
non-preferred paths (E1, E2, E3)
taking an exit branch
ICBM for a Simple RISC Processor - Step 2
Move code down through bypass branch
store 0 bypass
off-trace
code
c
c
c
E
E
branch store 1
E
branch
E
store 2
c0 c
c
branch
E
E
branch store 1
E
branch
E
store 2
c0 c
c
branch
E
branch store 1
E
branch
E
branch store 0 store 2
c0 c1 c
bypass
never
occurs
E
c
c
c
Superblock with bypass branch
ICBM for a Simple RISC Processor - Step 3
Code after downward motion
store 0 bypass
off-trace
code
c
c
c
E
E
branch store 1
E
branch
E
store 2
c0 c
c
branch
E
E
branch store 1
E
branch
E
store 2
c0 c
c
branch
store 0 bypass
off-trace
code
c
c
c
E
store 1
store 2
E
branch store 1
E
branch
E
store 2
c0 c
jump
Simplify resultant code