Presentation is loading. Please wait.

Presentation is loading. Please wait.

Eliminating Memory References Joshua Dunfield Alina Oprea.

Similar presentations


Presentation on theme: "Eliminating Memory References Joshua Dunfield Alina Oprea."— Presentation transcript:

1 Eliminating Memory References Joshua Dunfield Alina Oprea

2 Problem Definition – Register Promotion Memory-reuse analysis find loads and stores that access the same address and the execution path along which the reuse exists Program transformation promote values from memory to registers replace redundant loads and stores with register references

3 Different Approaches Memory-reuse analysis 1.Using the SSAPRE algorithm 2.Modeled as a data flow problem Program transformation Formulated as a PRE problem load a load b store c load d path 1path 2path 3 a = d on path 1 b = d on path 2 c != d

4 Different Approaches Memory-reuse analysis 1.Using the SSAPRE algorithm 2.Modeled as a data flow problem Program transformation Formulated as a PRE problem load a load d store c path 1path 2path 3 a = d on path 1 b = d on path 2 c != d load b

5 Register promotion using the SSA representation Paper: “Register Promotion by Sparse Partial Redundancy Elimination of Loads and Store” – Lo, Chow, Kennedy, Liu, Tu Register promotion = 2 problems: 1.PRE of loads 2.PRE of stores

6 Duality between loads and stores Loads – as ordinary expressions with respect to redundancy (have to delete the latter occurrences) Stores – reverse (have to delete the earlier occurrences) load a store a

7 PRE of loads Replace each store x expr by r expr x r where r is a pseudo-register Apply the SSAPRE algorithm, but take into account the occurrences of stores Effect of stores on loads: x rload x

8 Improving Code Motion in SSAPRE by Speculation Speculation = inserting computations during SSAPRE at  ’s where the computation is not down-safe (anticipated) Is not permitted by the original SSAPRE 2 strategies: conservative speculation (when profile data is not available) profile-driven speculation

9 Speculation Conservative Speculation Move loop-invariant computations out of single-entry loops (can perform worse if the body of the loop not executed) Profile-driven Speculation Pb of determining the optimum code placement is undecidable (solution between no-speculate and fully- speculate) Heuristics: do speculation at the granularity of the connected components of the SSA graph (for each connected component either no speculate or fully speculate)

10 PRE of Stores – SSU form Single Assignment Redundant Available, later Fully redundant Dominated (by earlier load) Where to factor Merge points Factoring op Insertion points iterated DF Movement Backward Use Anticipated, earlier Post-dominated (by later store) Split points iterated post-DF Forward LoadsStores

11 Performance PRE of loads reduces the number of loads by 25% PRE of stores reduces the number of stores by 1% Reasons: have already applied a dead store elimination algorithm Speculation results: conservative: same performance, even worse on some cases profile-driven: 2% reduction in the # of loads and 0.5% in the # of stores

12 Load-Reuse Analysis Paper: “Load-Reuse Analysis: Design and Evaluation” – Bodik, Gupta, Soffa Modeled as a data-flow problem 3-fold contributions: 1.load-reuse analysis supporting indirect memory accesses 2.simulation of the dynamic amount of load reuse 3.profile-based estimators: using edge profile information to assign a dynamic weight to the static load-reuse analysis

13 Framework

14 Load-Reuse Analysis Uses Value Name Graph (VNG) representation – keeps track of address expressions that compute the same value Traditionally – values identified by lexical name VNG supports symbolic equivalences Enhance VNG handle indirect addressing develop a sparse version (more space efficient)

15 VNG Example name = 2v +10 u = store (v-2) name = 2 (*u) +12 x = load (u) name = 2x+12 y = 2x+8 name = y+4 z = load (y+4) name = address of last load

16 Load-Reuse Analysis (cont) In computing symbolic names, do substitutions for w iterations for each loop Set the max no of indirection levels (0 or 1) Find congruence classes (names that refer to the same memory address) Extract a VNG sparse representation that contains only loads and stores Solve the data flow problem on the sparse VNG representation


Download ppt "Eliminating Memory References Joshua Dunfield Alina Oprea."

Similar presentations


Ads by Google